Archive: Nested or Combined Variables?


Nested or Combined Variables?
  Hello all.

I was wondering if the following is possible...


code…


>Var OutPut1
>Var OutPut2
>Var OutPut3

>;depending on how the script runs, $0 will be 1, 2, or 3.

Loop:
>StrCmp $0 0 End
SrtCpy $OutPut
$0 blabla
IntOp$0 $0 - 1
Goto Loop

End
>
So some or all of my 3 OutPutX variables will get loaded up with strings. The problem I’m having is the "$OutPut$0" code above. This of course does not work. Can I nest or combine variables? I can get around this by not using a loop, and just have 3 chunks to potentially load up each OutPutX variable, with a "StrCmp $0 0 End" before each. I would just like to use a loop if I can, I really have 13 OutPutX variables. Thanks.

You can use defines in variable names, e.g.
!define Num 0
StrCpy $OutPut${Num} "blabla"
...except this would be pointless as you cannot increment the value of the define on compile-time.

You will just have to use 13 lines of StrCpy to do it.

If you like, you could put it in a seperate macro and then use !insertmacro

E.g.
!macro SetVars Val
StrCpy $OutPut1 "${Val}"
...
!macroend

!insertmacro SetVars "blabla"

-Stu


Thanks Stu.