[fpc-pascal] Is there a range limitation for the in operator?

Bo Berglund bo.berglund at gmail.com
Wed Dec 22 15:59:06 CET 2021


I have been debugging a file analyzer program which is supposed to show a record
if one clicks in the hex representation of the binary file content.

I have a function which will grab the start and length of a record given the
address clicked on.

The file contains several different sections, basically:
- header (30 bytes)
- array of type 1 records (n * 14 bytes)
- array of type 2 records (m * 25 bytes)
The counts m and n are available in the header record as word size values.

So I have this construct to translate theinput address into a start and length
result:
if Addr in [0..sizHd-1] then  //Clicked in the header
begin
  //Calculate start and end address of header
end
else if Addr in [(sizHd)..(sizHd + sizGeos -1)] then
begin
  //Calculate start and end address of clicked record in array
end
else if Addr in [(sizHd + sizGeos)..(sizHd + sizGeos + sizCmds -1)] then
begin
  //Calculate start and end address of clicked record in array
end;

This seemingly worked fine until I clicked inside the area of he type 2 records,
when the execution never got to the last calculation...

So I changed the code from using "in" to this instead:

else if (Addr >= strtCmds) and (Addr < (strtCmds + sizCmds)) then

Where I previously have done this:
strtCmds := strtElecs + sizGeos;

Now it works as planned....

So I wonder if there is a value range limitation for the arguments inside an in
command like:
if a in [x..y] then

???


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list