[Lazarus] Fwd: AV exception error on "lower1 := left" (integer variable assignment)... Can anyone explain this???
Peter E Williams
pewtas at gmail.com
Sun Apr 24 00:59:17 CEST 2011
Hi All,
I am having a problem with a strange run-time AV error. See the link to the
Lazarus project.
Download link:
http://hotfile.com/dl/115480488/6b7a8ed/dtm_maker_001.zip.html
The problem is in the QSort procedure:
Procedure QSort( Var island_single_array : island_single_type;
left, right : integer);
Var
d : island_single_type;
pivot,
lower1,
upper1 :integer;
begin
lower1 := left;
// ^^^^^^ AV run-time exception on above line.
upper1 := right;
pivot := island_single_array[left].location_number;
While (left < right) do
Begin
Case SortType of
ascending : begin
While (island_single_array[right].location_number >=
pivot) and (left < right) do
dec(right);
if (left <> right) then
begin
swap(island_single_array[left],island_single_array[right]);
inc(left);
end;
While (island_single_array[left].location_number <=
pivot) and (left < right) do
inc(left);
if (left <> right) then
begin
swap(island_single_array[left],island_single_array[right]);
dec(right);
end;
end;
end; // case
end; // while
pivot := island_single_array[left].location_number;
left := lower1;
right := upper1;
if left < pivot then
QSort(island_single_array,left,pivot-1);
if right > pivot then
QSort(island_single_array,pivot+1,right);
end; { QSort }
{--------------------------------------------------------------------}
procedure QuickSort( Var island_single_array : island_single_type;
Size : integer);
begin
QSort( island_single_array, 1, Size );
end;
{--------------------------------------------------------------------}
The AV exception error occurs after the project is run then the user selects
File / Save and the QuickSort procedure is called which then calls Qsort.
The error is occurring on:
lower1 := left;
which are both integers. Lower1 (which was renamed just in case of a name
conflict with the 'lower' string function) is ??? (unassigned) and left is
1. I see no problem with this statement and it is a mystery to me why I am
getting an AV exception error.
Maybe someone here with better debugging skills can tell me why is this
happening and how to fix it.
Best Regards,
Peter / pew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110424/8cc5d985/attachment-0003.html>
More information about the Lazarus
mailing list