Re: how to deal with problem:Loop limit expression too large for loop variable type. [message #59650] |
Fri, 04 April 2008 05:24  |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
Magic.Zhou@gmail.com wrote:
> i just code a for function
> for i=0, ArraySize do begin
> if (Seg_Grey_Image[i] le 255) and (Seg_Grey_Image[i] ge 240) then
> begin
> Seg_Grey_Image[i]=255
> endif
> endfor
> however, the error is :Loop limit expression too large for loop
> variable type.
> it seems this 'ArraySize' is too big. how can I deal with this
> problem?
> Thank you!
Change:
"for i=0, ArraySize do begin"
to
"for i=0L, ArraySize do begin"
(note the addition of a capital 'L' after the zero).
If you set your loop variable to be a normal (2 byte) integer you can
only loop up to 32,768. Adding in the 'L' sets it to a long (4 byte)
integer.
Thanks,
Allan
|
|
|
|