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

2021-12-22 Thread Bo Berglund via fpc-pascal
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

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

2021-12-22 Thread Sven Barth via fpc-pascal
Bo Berglund via fpc-pascal  schrieb am
Mi., 22. Dez. 2021, 16:08:

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

The right side of the in-operator is a set constructor. And sets may only
contain up to 256 values. (Though I don't know right now whether that is
always counted from 0 or not)

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

2021-12-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Dec 2021 17:07:55 +0100, Sven Barth via fpc-pascal
 wrote:

>Bo Berglund via fpc-pascal  schrieb am
>Mi., 22. Dez. 2021, 16:08:
>
>> So I wonder if there is a value range limitation for the arguments inside
>> an in
>> command like:
>> if a in [x..y] then
>>
>
>The right side of the in-operator is a set constructor. And sets may only
>contain up to 256 values. (Though I don't know right now whether that is
>always counted from 0 or not)
>

Ok, thanks. Figured that it was something like that.
So I have to stack several if conditions instead.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal