Page 1 of 1

How do you define and initialize a global variable?

Posted: 03 Jan 2016 06:26
by rgames
I assumed that global variables are defined immediately under the "Project" heading at the top of the project hierarchy. Also, I assumed that the blue numbers next to them are the initial values. If so, then in the attached image, all the names with green dots next to them are global variables, correct?

And the blue numbers are the initial values, correct?

I have a bug where the global variable "sendLibrariesCC" is not being read correctly by a script (if it is, in fact, a global variable...). I set the value in one script, then another script executes with an "if" statement dependent upon the value of that variable. However, the script is not executing properly given the state of the variable. So I'm just trying to confirm that I do, in fact, have a global variable. If the variable is not global then that could explain the behavior.

I can't find this info in the manual.

Thanks,

rgames

Re: How do you define and initialize a global variable?

Posted: 03 Jan 2016 13:50
by MrCorba
Those are indeed global variables. Those variables can be read/changed from anywhere.The blue numbers represent the initial values given to them. If you change the value with a script those blue numbers won't change(unfortunately).. So I guess there is an error in your execution script.

Cheers!

Re: How do you define and initialize a global variable?

Posted: 03 Jan 2016 16:16
by rgames
Great- thanks!

Off to look elsewhere for the problem...

Re: How do you define and initialize a global variable?

Posted: 03 Jan 2016 19:47
by microtonal
MrCorba's response is correct. Elaborating a bit, if you want to use a variable across multiple scripts, it must be defined as a global variable at the project level. Some projects will define the variable as zero and automatically regenerate the needed values in the scripts. Global arrays are also defined this way, but values are always defined in the scripts.