GLBasic forum

Main forum => GLBasic - en => Topic started by: ampos on 2011-Jan-03

Title: non-changeable variables
Post by: ampos on 2011-Jan-03
I know they exists, but I can not find the command

Is like asigning a variable a value, but this value is untochable. In fact, the compiler changes the variable name with the variable value.

mysprite=7
drawsprite mysprite,x,y

will be compiled as

drawsprite 7,x,y

Damm alzheimer...
Title: Re: non-changeable variables
Post by: DVD Guy on 2011-Jan-03
My first post  :nw:

Hi ampos,

try

CONSTANT mysprite%=7

Note that you can later attempt to change the value in code (e.g. CONSTANT mysprite%=12) and the program will compile, but the value will not change.  Referencing it without the CONSTANT keyword will generate a compile-time error.

Title: Re: non-changeable variables
Post by: MrTAToad on 2011-Jan-03
Actually, attempting to change a CONSTANT will generate error: assignment of read-only variable `__GLBASIC__ compiler error.
Title: Re: non-changeable variables
Post by: ampos on 2011-Jan-03
And why the hell it is not in the user manual?  :rant:
Title: Re: non-changeable variables
Post by: Kitty Hello on 2011-Jan-05
Because it's not stable in all ends. If you're tricky, you can change the value.  :-[
Title: Re: non-changeable variables
Post by: MrTAToad on 2011-Jan-05
QuoteIf you're tricky, you can change the value.
I've never been able to :)  If its still possible then most require some very tricky fiddling :)
Title: Re: non-changeable variables
Post by: Kitty Hello on 2011-Jan-07
I think passing it BYREF to a function might be able to.