forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Setting a variable

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
MarkJordan



Joined: 18 Jan 2006
Posts: 11

PostPosted: Wed Jun 06, 2007 3:28 pm    Post subject: Setting a variable Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7926
Location: Salford, UK

PostPosted: Fri Jun 08, 2007 10:05 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
MarkJordan



Joined: 18 Jan 2006
Posts: 11

PostPosted: Fri Jun 08, 2007 12:03 pm    Post subject: Reply with quote

Paul

Thanks - I will try it in a separate program

Regards

Mark Jordan
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Fri Jun 08, 2007 4:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
MarkJordan



Joined: 18 Jan 2006
Posts: 11

PostPosted: Fri Jun 08, 2007 11:06 pm    Post subject: Reply with quote

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.Cool 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)

Sad

As I said all this worked ok with 4.9

Regards

Mark
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Sat Jun 09, 2007 10:14 am    Post subject: Moving on Reply with quote

Mark,

What are you trying to do with this code?

Ian
Back to top
View user's profile Send private message Send e-mail
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7926
Location: Salford, UK

PostPosted: Mon Jun 11, 2007 2:26 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
brucebowler
Guest





PostPosted: Mon Jun 11, 2007 3:36 pm    Post subject: A forum wide request Reply with quote

[quote="MJ43"]

IF (i4BitSize.LT.Cool 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
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group