|
|
|
|
#1 |
|
Junior Member
Join Date: Nov 2005
Location: Delta, BC
Posts: 23
|
I tried this and it did not work. I thought I would ask here to see if there was a way to do this..
Lets say we have some variables: Var vr1 Var vr2 Var vr3 Now I wish to access variable "$vr1" like this: StrCpy $0 "1" IntOp $vr$1 $vr$1 + 1 (should be the same as "IntOp $vr1 $vr1 + 1" ) Is there a way to achieve this? Thanks Lane |
|
|
|
|
|
#2 |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
I don't think what you want is possible the way you have shown it.
If you want to do this during compiletime, use macros. e.g., code: At runtime, you can probably use a Function code: However, I am not sure if this is what you are looking for. What exactly are you trying to do with these "dynamic" variables? |
|
|
|
|
|
#3 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
If you're trying to do an array of data, you can try my NSISArray plugin.
http://nsis.sf.net/File:NSISArray.zip -Stu |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Nov 2005
Location: Delta, BC
Posts: 23
|
I should have explained better.
What I am trying to do, is to read 16 different values from an INI file (State and Text) and place each one into a matching named NSIS variable. I have this working, but it would be really nice if I could just put it into a "loop". Would make the scipt easier to read and more maintainable. To put this into a program loop, I need to be able to use what I was calling "dynamic" NSIS variables. Can you suggest a method to do this? Thanks Lane |
|
|
|
|
|
#5 |
|
Member
|
StrCpy $0 "1"
IntOp $vr$1 $vr$1 + 1 Shouldn't $0 actually be $1? You're setting the integer 1 to the variable $0. But in the next line, when you're trying to run an integer operation on it, you're trying to run it on $vr$1, and you never set anything to $1. Maybe I'm missing something here, but I don't see where else $0 comes into play. |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Nov 2005
Location: Delta, BC
Posts: 23
|
Yes, that was a "typo" on my part..
It should have been $vr$0 |
|
|
|
|
|
#7 |
|
Member
|
Okay, well in that case, I think you are using the IntOp operation on the wrong variable. You are using it on $vr$1, expecting it to increment the variable vr1 to become vr2. That won't happen, because it can not add an integer "1" to a string "vr1".
You should run IntOp on $0. IntOp $0 $0 + 1 This way, the initial value "1", on the next loop becomes 2, and therefore the new variable that $vr$0 would access is "vr2". At least I think that's what should be happening. |
|
|
|
|
|
#8 |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
The best suggestion is probably Afrow UK's NSISArray plugin.
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Nov 2005
Location: Delta, BC
Posts: 23
|
Yes, that is what I initially thought too.
But it seems the substituting "$vr$0" for "$vr1", does not work. (where $0 was set to "1"). It works in normal string substitution, but not when you need it to refer to an NSIS variable. That is what I have been trying to get going... Lane |
|
|
|
|
|
#10 |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
That's because the substitution is being done at compiletime, not runtime.
At compile time, the compiler extracts a token named $vr$0 from the command. It then tries to resolve the token and sees that it consists of two variables: $vr and $0. When it tries to resolve $vr it fails. |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Nov 2005
Location: Delta, BC
Posts: 23
|
Yes, I understand what is happenig now.
Perhaps a future NSIS release could support something like this, or could have native array support! Thanks Lane |
|
|
|
|
|
#12 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
I think that that would just add to the installer overhead.
Edit: If you want to clean up your code, use a macro and insert it multiple times. -Stu |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jan 2005
Location: Look behind you.
Posts: 209
|
Upgrade to NSIS 2.11 and use the !tempfile, !appendfile, and !delfile commands to dynamically generate script files.
-dandaman32 ExperienceUI for NSIS | Latest project: Enano CMS Do not PM me on the Winamp forums, I hardly ever check my messages here; you are more likely to get my attention through the ExperienceUI forum.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|