compound variables
:setvar a “!!b” # B is not referenced, 2!’s fold to 1
:echo b is !b, a is !a b is 123, a is 123
:echo Compound var "a!!b": !"a!b” Compound var "a!b": xyz
:setvar J 2 :setvar VAL2 “bar” :setvar VAL3 “foo”
- :calc VAL!J bar
- :calc VAL![J] bar
- :calc VAL![decimal(J)] bar
- :calc VAL![setvar(J,J+1)] foo
Notes:
- The CI allows two or more variable names to be concatenated to form a new variable name, and to reference the value of this name-derived variable.
- A common application of compound names is variable arrays, discussed next.
- The value of a variable can reference another variable, e.g.. :setvar color “red” :setvar bg “!!color” :showvar bg BG = !color :echo 123 !color 456 123 red 456