SRL Archive - OSR Help

Get total number of indexes in array


xxpoopyxx

2013-03-14 16:37:52

how would i get the number of indexes in an array?

for example

 for i := 0 to ArrayCount do 

DannyRS

2013-03-14 16:38:34

Integer := High(ArrayName);

? At least I think thats what you are after :p


for i := 0 to High(ArrayName) do
ArrayName[i] := i;

wthomas

2013-03-14 16:42:49

You could also use Length() ie.

for i := 0 to length(ArrayName)-1 do
ArrayName[i] := i


xxpoopyxx

2013-03-14 16:48:57

Yes perfect!! thank you both!

DannyRS

2013-03-14 16:56:28

From: wthomas
You could also use Length() ie.

for i := 0 to length(ArrayName) do
ArrayName[i] := i



Length is High() + 1, so that would throw out of range runtime error,


for i := 0 to (length(ArrayName)-1) do
ArrayName[i] := i

wthomas

2013-03-14 17:02:08

From: DannyRS
Length is High() + 1, so that would throw out of range runtime error,


for i := 0 to (length(ArrayName)-1) do
ArrayName[i] := i


Derp. my bad :)