Awesome, just had a few minutes to look at the global variables that come
with 6.01 upgrade of K2 as I could not find documentation on this and I thought
I would share :)
So what are global variables and why should you care.
With K2 we started to using nested If statements which is great but one of
the problems with the nested If statements is normal script variables can’t be
called/read from line outside the nested “If statements” so most of us had to “echo”
the variable data out to a text file and then read it back into variable in the
next “If statement” E.g.:
If Y exists
Log #varX# (outputs 2)
Agent Log #varX# (outputs 1)
The other problem with it is if you don’t or can’t output
your variables to a text file you end up having to duplicate a lot of lines.
With K2 service pack 1 comes the global variable that allows us with a
simple prefix change a normal script variable into a global variable that can
be read outside the nested “If statement”, including other nested “If statement”.
# varX# (outputs 3)
Log # global:varX# (outputs 2)
Agent Log # varX# (outputs 1)
Agent Log # global:varX# (outputs 2)
Sorry if my explanation does not make any sense, but feel
free to ask if you don’t understand.
Actually that does make sense. I didn't even realize that variables had scope in Kaseya scripts. Thanks!