GLOBAL previousGeneratedNumber = 0
Do
Sleep( 500 )
randomNumber = Randomize()
Sync()
Loop
Function Randomize()
While ( returnValue = previousGeneratedNumber )
returnValue = Random( 1, 5 )
EndWhile
Print( Str( previousGeneratedNumber ) )
Print( Str( returnValue) )
previousGeneratedNumber = returnValue
EndFunction returnValue
In my code, I'm expecting to generate a random number from 1 to 5 but not equal to the previously generated number. However, while I'm checking the output, I noticed that the value of previousGeneratedNumber returns to 0 every loop.
What is the behavior of global variable in AppGameKit?
Does the variable return to it's default value every time it is used within a function?