|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| Var creates the local variable in the current routine and can only be referenced from inside this routine.
| | #Redirect [[Local Variables]] |
| | |
| The difference between /var and [[/set]] is that var creates local variable what only exists while script is executed. Set sets value to variable and stores it there until it's [[unset]]. Local variables doesn't overwrite variables set with "set" command values.
| |
| | |
| You can set multible variables with one set
| |
| var %x = foo, %y = bar
| |
| | |
| Usage of = in syntax is optional
| |
| var %x foo
| |
| | |
| You can use /var -s to make a variable show the result when a value is set.
| |
| | |
| == Example ==
| |
| | |
| First, let's create [[Aliases|alias]] needed later on.
| |
| alias var_example { var -s %x foo | set -s %y bar }
| |
| | |
| Now, let's play around.
| |
| | |
| ; set values to variables with set so values exists until they're unset
| |
| set %x 10
| |
| set %y %x
| |
| ; value fro %x is copyed to %y (for users from with previous knowledge from scripting)
| |
|
| |
| ; call of your own alias
| |
| var_example
| |
| ; displays
| |
| ; * Set %x to foo
| |
| ; * Set %y to bar
| |
|
| |
| ; now, let's display %x and %y values
| |
| [[echo]] -a %x
| |
| ; returns 10
| |
| [[echo]] -a %y
| |
| ; returns bar
| |
| | |
| As we can see, %x still holds it origial value because /var creates only local variable, but %y was overwritten with /set.
| |
| | |
| [[Category:Local_Variables]]
| |