Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scope / global variables
#1
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.
 
Code:
Copy      Help
public class Globals
{
    
    public static int num1;

}


Thanks in advance
#2
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?
#3
https://www.libreautomate.com/forum/show...p?tid=7759


Forum Jump:


Users browsing this thread: 5 Guest(s)