i want that "cat" to be a like a word, that appends to any other word i want within the script, so that by just changing set %var1 cat... to lets say set %var1 gorilla, now the word gorilla has replaced every word "cat" that was originally in the script.
I see what you mean. rbhibbs seems to have understood the same thing and he pointed you to the right direction. I'll just explain the same concepts going slowly from dynamic parameters to dynamic variables.
Anyway, what you want can be done in a similar way as my previous (off-topic) example: with $+(). For example, you can have in your script:
...
echo -a $+(hello,%var1,world)
Whenever this script executes, it will echo "hello<current value of var1>world". Try these to see what I mean (btw, any commands you see from now on that start with double // are meant to be run from an editbox, like Status Window):
//var %var1 = big | echo -a $+(hello,%var1,world) | var %var1 = small | echo -a $+(hello,%var1,world)
(dynamic parameters)
//var %var1 = cho 3 -a | e $+ %var1 hello | var %var1 = cho 4 -a | e $+ %var2 hello
(dynamic commands)
However, there are certain limitations. You can use this technique to dynamically change the parameters of commands/identifiers or even the commands themselves, but you can't use this in alias definitions. Aliases must have static names, eg you can't have something like
alias %var1 {
echo -a Hello!
}
With variables, what you want is possible but requires a bit more complex code. Let's take a look at your example %(%var1 $+ var2)
To /set such a variable in a script, you need this:
set $+(%,%var1,var2) somevalue
To retrieve the value of a variable like this in a script you need
$eval($+(%,%var1,var2),2)
Ie the script must first construct the variable name. When setting, this is enough. When retrieving the value, however, the newly constructed variable name must be evaluated, and that's where $eval(...,2) comes in. A bit lengthy solution, but works. Here's an example snippet for the 2nd case (retrieving a value):
//var %catfood = fish, %dogfood = meat | var %var1 = dog | echo -a $eval($+(%,%var1,food),2) | var %var1 = cat | echo -a $eval($+(%,%var1,food),2)
(dynamic variable)