View previous topic :: View next topic |
Author |
Message |
MarkJordan
Joined: 18 Jan 2006 Posts: 11
|
Posted: Wed Jun 06, 2007 3:28 pm Post subject: Setting a variable |
|
|
When trying the following
i1SetMask=b'11111111'
i2SetMask=b'1111111111111111'
I get the error 'constant out of range' with v5.01.0
but v4.9.0 and earlier seem to work ok |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Fri Jun 08, 2007 10:05 am Post subject: |
|
|
I have tested your code fragment using FTN95 v5.10 (the current release) and it does not show any errors.
I do not have immediate access to a copy of version 5.01 so I do not know if there is a problem with this version. I cannot think of any changes
to FTN95 that would be relevant. You can upgrade to 5.10 but before doing so I suggest that you test the fragment using your copy of version 5.01. It is possible that something else in the original program is causing the problem. |
|
Back to top |
|
|
MarkJordan
Joined: 18 Jan 2006 Posts: 11
|
Posted: Fri Jun 08, 2007 12:03 pm Post subject: |
|
|
Paul
Thanks - I will try it in a separate program
Regards
Mark Jordan |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Fri Jun 08, 2007 4:37 pm Post subject: |
|
|
I've had that as well in the latest version of FTN95.
If it is Integer*2, then 16 binary digits is the limit, and the value you are trying to enter is actually -1, 1111111111111111 being the twos complement representation.
try
i2SetMask= -1
Regards |
|
Back to top |
|
|
MarkJordan
Joined: 18 Jan 2006 Posts: 11
|
Posted: Fri Jun 08, 2007 11:06 pm Post subject: |
|
|
Paul
Program Fred
INTEGER*1 i1Mask
i1Mask=b'11111111'
END
fails with the error constant out of range
so I followed Ian's suggestion
! i1SetMask=b'11111111'
! i2SetMask=b'1111111111111111'
i1SetMask=-1
i2SetMask=-1
i4SetMask=b'11111111111111111111111111111111'
!
i4BytePt=ISHFT(i4BitPt, -3) ! Divide by 8
i4BitOffset=i4BitPt-ISHFT(i4BytePt, 3) ! Multiply by 8
i4BitSize= i4NumBits+i4BitOffset
!
IF (i4BitSize.LT. THEN
i1RightShift=(8-i4NumBits) ! How many bits to remove
it avoids the constant out of range error
but it now fails on Operand incompatible with opcode on the line
i1RightShift=(8-i4NumBits)
As I said all this worked ok with 4.9
Regards
Mark |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Sat Jun 09, 2007 10:14 am Post subject: Moving on |
|
|
Mark,
What are you trying to do with this code?
Ian |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Mon Jun 11, 2007 2:26 pm Post subject: |
|
|
A range check for INTEGER*1 and INTEGER*2 was introduced for /CHECK (and options that include /CHECK) at version 5.0 of FTN95.
You can avoid the problem by using constants of the required integer KIND.
i1SetMask=b'11111111'_1
i2SetMask=b'1111111111111111'_2
Then the conversion from default integer KIND does not take place and the range check is avoided. |
|
Back to top |
|
|
brucebowler Guest
|
Posted: Mon Jun 11, 2007 3:36 pm Post subject: A forum wide request |
|
|
[quote="MJ43"]
IF (i4BitSize.LT. THEN
[/quote]
MJ43, this is NOT a personal attack on you, PLEASE don't take it that way!!!
Please excuse my hijacking this thread to complain about smilies, but in code, smilies/emoticons tend to "get in the way" of making sense of code. Would it be possible to get the state of smilies to be "off by default" so that people have to make a conscious effort to mess up posted code? |
|
Back to top |
|
|
|