Retrieveing a global variable readonly to a local variable
Posted: Sun Mar 03, 2024 11:39 pm
Is there a more elegant solution to retrieve the value of a global variable without defining one?
This is a just minimal example but instead of the fixed value "foo" it could also be something dynamic such as [:jobname].
At the moment I'm just experimenting a bit with with what's possible. The basic idea is that the same script could be used multiple times but with different names and by usin :jobname each could have its own configuration without changing the script.
The second idea is that without defining a global varible it cannot be changed. (The downside is that this script needs more permissions than just defining a global variable...)
(It's not needed for anything, I just want to learn about what's possible with scripting.)
Code: Select all
:local name "foo";
:local value [/system/script/environment/get [/system/script/environment/find name="$name"] value];
At the moment I'm just experimenting a bit with with what's possible. The basic idea is that the same script could be used multiple times but with different names and by usin :jobname each could have its own configuration without changing the script.
The second idea is that without defining a global varible it cannot be changed. (The downside is that this script needs more permissions than just defining a global variable...)
(It's not needed for anything, I just want to learn about what's possible with scripting.)