Global Variables

Freedo

New member
Joined
Oct 1, 2020
Messages
6
Variables declared as global not recognised in A function. (error variable not defined)... is there A work around..?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,298
They should be. Make sure that the casing is correct. myVariable and myvariable are different variables.
If you don't find the error in your code, please post it.
 

Freedo

New member
Joined
Oct 1, 2020
Messages
6
Thanks. looks to be when trying to place function outside of the Class Extends App. now inside the global variables are recognised.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,298
So your global variable is inside a class but you want to access it outside the class inside a function??

If that is the case, place the class identifier in front of your global variable.

Cerberus:
Strict

Global myGlobal2:Int = 5

Class myClass
    Global myGlobal:Int = 6
End

Function Main:Int()
    Print myClass.myGlobal
    Print myGlobal2
    Return 0
End

but I must say that this would be a very weird case of usage.
 
Top Bottom