westy100697
asked on
Using Variant Arrays
My question is this. I am using the type variant in a program I am writing. Now I created an array using
varArrayCreate and I will put some sample sode below. Now it is easy to read data into the variant array except when you get to the last record to read in and I keep getting list index out of bounds. Now I have tried a few different things to try and stop giving me this error. For example, if I made
the following array
tempArray := varArrayCreate([1,10],varV ariant) I tried to
read in only up to tempArray[9] and still get list index is out of bounds. Now this is imossible since I am not at the end of the array. Very strange and if anyone can shed some light on this let me know. I must to doing some damn simple
the wrong way. I had a full head of hair before this problem came up. Cheers.
If (Table2.Findkey([TempJobNo ]) = false) then
begin
TotalFields := Table1.FieldCount ;
TempArray := varArrayCreate([0,TotalFie lds-1],var Variant);
For i := 0 to TotalFields-1 do
begin
TempArray[i] := Table1.Fields[i].AsVariant ;
Table1.Next ;
TempJobNo := Table1.Fieldbyname('JOB_NO ').AsStrin g ;
end
else
begin
Table1.Next ;
TempJobNo := Table1.Fieldbyname('JOB_NO ').AsStrin g ;
end;
end;
{THANKS IN ADVANCE ANYONE}
varArrayCreate and I will put some sample sode below. Now it is easy to read data into the variant array except when you get to the last record to read in and I keep getting list index out of bounds. Now I have tried a few different things to try and stop giving me this error. For example, if I made
the following array
tempArray := varArrayCreate([1,10],varV
read in only up to tempArray[9] and still get list index is out of bounds. Now this is imossible since I am not at the end of the array. Very strange and if anyone can shed some light on this let me know. I must to doing some damn simple
the wrong way. I had a full head of hair before this problem came up. Cheers.
If (Table2.Findkey([TempJobNo
begin
TotalFields := Table1.FieldCount ;
TempArray := varArrayCreate([0,TotalFie
For i := 0 to TotalFields-1 do
begin
TempArray[i] := Table1.Fields[i].AsVariant
Table1.Next ;
TempJobNo := Table1.Fieldbyname('JOB_NO
end
else
begin
Table1.Next ;
TempJobNo := Table1.Fieldbyname('JOB_NO
end;
end;
{THANKS IN ADVANCE ANYONE}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to be of help Westy!
You'll have to reject or accept the answer before the Expert Exchange system will clear it from the list of QX's awaiting answers.
Regards
Pegasus
You'll have to reject or accept the answer before the Expert Exchange system will clear it from the list of QX's awaiting answers.
Regards
Pegasus
ASKER