Globals as function default values?

Previous topic - Next topic

bigtunacan

Should global variables be able to be used as the default value of a Function variable?

I am trying to do something like this.

Code (glbasic) Select

GLOBAL MIRR_NORMAL=1
GLOBAL MIRR_VERT = 2
GLOBAL MIRR_HORIZ = 4

FUNCTION draw_named_sprite: name$, x, y, mirror=MIRR_NORMAL
   // draw a re-usable sprite straight out of fresh can of tuna... yummy
ENDFUNCTION


The compiler barks at me with this error message.

Quotegpc_temp.h:13: error: `MIRR_NORMAL' was not declared in this scope

Slydog

#1
Two suggestions:

1. Use CONSTANT instead of GLOBAL

2. Or, make sure the file your GLOBALs are defined in are compiled before any project file that uses them in functions.
    View the project file in a text editor, the bottom section lists every file in your project in the order they are compiled!
    Cut / paste those files to be in the order you need. 
    (or I think they are now compiled alphabetically?  So rename them alphabetically in the desired order)
    If it's in the same file, then put them at the top.
    Not sure if this is the problem however.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

bigtunacan

@Slydog,

Thanks; CONSTANT is what I'm really looking for and it does work here.  CONSTANT is not listed in the documentation.  Is this a new/beta feature?  And to that end is there a listing somewhere of new/semi-supported features somewhere so one knows what all is available for the "cutting edge"?

naina

The above discussion was very useful for my project..Thanks a lot.
Be positive and keep smiling