In response to
another thread, I would like to pose this suggestion to Khaled.
Presently, %variables set with /var have a scope that is limited to the confines of the alias that it was created in... and they cannot be seen by sub-aliases. I propose for sub-aliases to be allowed to see the parent's /var %variables as if they were global variables, and have the ability to modify them.
If they want to use a variable of the same name, they simply initialize it with the /var command as normal.
Here are some examples:
/alias-one {
; create a global variable
set %somevar GLOBAL-ONE
/alias-two
; the data from %somevar is "GLOBAL-TWO" because it was changed in /alias-two
echo -a %somevar
}
/alias-two {
; change the value of the global variable
%somevar = GLOBAL-TWO
; create a local variable that superceeds the global variable
var %somevar = LOCAL-TWO
/alias-three
; the data from %somevar is "HI ALIAS TWO", and will die when this alias ends,
; because it was initialized here with the /var command.
echo -a %somevar
return
}
/alias-three {
; display the data from %somevar. normally it would have displayed "GLOBAL-TWO"
; but since it existed in the parent alias, we will see "LOCAL-TWO".
echo -a %somevar
; we can change its value too, and the alias will still be "local" and die in /alias-two.
%somevar = "HI ALIAS TWO"
; now we create a variable of the same name, but it will be local to this alias only.
var %somevar = LOCAL-THREE
return
}
- Raccoon