Hi Carrol,

> How would this differ from local variables?
Well, local variables differ in two main attributes from static 
variables:
1. Local variables are only visible in the "location" (function) 
where they are defined. If you want to use a local variable in 
another function of the same script, then you have to pass it via an 
argument or parameter.
2. Local variables loose there values with the end of the 
"location" (function), where they are defined. So you can't use local 
variables to remember informations for a following run of the script.

In PowerPro static variables are global variables restricted to one 
script-name! (If you would have two different scripts with the same 
name but stored in different locations, they would share those static 
variables with the same name).
1. Static variables are visible in the whole script, i.e. in all 
functions.
2. Static variables don't loose there values with the end of the 
"location" (function) where they are defined, nor with the end of the 
script. So you can use them to remember informations for a following 
script-run.

Of course one should try to avoid global/static variables, because 
they are somehow dangerous and it's very hard to keep them under 
control if the program or script is of a remarkable size. But in my 
experience it's more or less impossible to live without such 
variables, because you can't allways pass lots of parameters to each 
function. I.e. any kind of text, which might be translated if you 
want to support multilingual software.
  
> If you get a new set of static variable each time you run the
> script then they can't be used to remember values between runs.
My proposal to Bruce contains the option to run a script as now 
(let's say only one default-instance) or as a new instance of the 
script.

In my case i have a script using Alan's dialog-plugin supporting 
multilingualism. All texts are defined in language-files as static 
variables - so they are visible all over the script. Also some 
control-flags are defined as static-variables - so i can remember 
informations of the last dialog-step.  
The problem is: the user could run this script more than once at the 
same time - I did it with another language - and i was very surprised 
about the effects. 
Currently i implemented a check to block paralell processing of the 
script. But if i could have a new instance of the script with a new 
set of static variables, there wouldn't be any problem, if PowerPro 
can remember the script-instance related to the current dialog.

It's not so important for me, because i can block paralell 
processing. It's just the idea of improving things, but only if they 
don't get to difficult.

Best regards Detlef










Reply via email to