non-changeable variables

Previous topic - Next topic

ampos

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

DVD Guy

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.


MrTAToad

Actually, attempting to change a CONSTANT will generate error: assignment of read-only variable `__GLBASIC__ compiler error.

ampos

And why the hell it is not in the user manual?  :rant:

Kitty Hello

Because it's not stable in all ends. If you're tricky, you can change the value.  :-[

MrTAToad

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 :)

Kitty Hello

I think passing it BYREF to a function might be able to.