Posts: 58
Threads: 20
Joined: Aug 2019
Hello again,
I'm attempting to store/call on variables globally.
I tired the following using the class below,
but then when attempting to store and retrieve from a different script, calling Globals.num1 , I cannot seem to store values. It always comes to value 0.
public class Globals
{
public static int num1;
}
Thanks in advance
Posts: 12,058
Threads: 140
Joined: Dec 2002
Scripts run in separate processes. Even the same script runs in new process each time. Each process has its own static variables, and they disappear when the process ends. There is no variable scope that spans multiple processes.
If you used QM, its global variables have the same lifetime as the QM process. And QM macros by default run in QM process. Now, when you use LA, do you need global variables that have the same lifetime as the LA process? Or should they persist even longer? Or shorter?
To share values between processes, can be used a file, registry, shared memory, etc, depending on how you want to use them. It's possible to implement it. But the implementation and usage depends on the variable type (simple types like int, strings, arrays, class/struct). Can you give a description and example of where/how you will use such variables?
Posts: 12,058
Threads: 140
Joined: Dec 2002