Declaring a Variable used from Command Line
Hello,
Can anyone give me a fast explanation? I am confused as how to pass command
line references in SB5.
If I put:
If %FROMINSTALLER% Equals "1" Then
Set Installer Flag $SB_REMOVEINSTALLER$ to 1
End
It won't compile saying I have to Declare the Variable.
The only way I know how to Declare a Variable in Setup Builder is to use the
"Set Variable".
Well, when I do that ... I delcare it as "0" so all it does it must be
overriding my passed command line 1 to a 0.
I am using:
myprogram.exe /V FROMINSTALLER 1
When I run it, it's always zero. How do you declare a variable so the
script compiles, but not overwrite the variable that is coming in from the
command line?
Seems like a catch-22 to me.
I must be missing the obvious
-Robert
Re: Declaring a Variable used from Command Line
Hello,
The only workaround I found was to use _SB_PARAM1 instead of my own
variable.
Is that correct?
-Robert
Re: Declaring a Variable used from Command Line
Hello Robert,
You only have to declare the variable in your script (before you use it) ;-)
Set Variable %FROMINSTALLER% to 0
Display Message Box "%FROMINSTALLER%" -- ""
Then use this:
myprogram.exe /V FROMINSTALLER 1
Does this help?
Friedrich
--
Friedrich Linder
CEO, Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 5
Re: Declaring a Variable used from Command Line
If I set the variable to zero. Why does that not override what is being
passed on the command line?
That's what it seems to be doing.
Which makes sense. If I set the FROMINSTALLER variable to zero in the
script, and it's 1 coming in the script, then using Set will just overwrite
it.
-Robert
Re: Declaring a Variable used from Command Line
The first variable declaration always receives the variable value passed
through the command line.
For example, the following code:
Line 1 Set Variable %FROMINSTALLER% to 0
Line 2 Display Message Box "%FROMINSTALLER%" -- ""
Line 3 Set Variable %FROMINSTALLER% to 2
Line 4 Display Message Box "%FROMINSTALLER%" -- ""
I am using this:
myprogram.exe /V FROMINSTALLER 1
Line 1: The command line parameter set the %FROMINSTALLER% variable to 1
Line 2: "1" is displayed
Line 3: the script set %FROMINSTALLER% variable to 2
Line 4: "2" is displayed
To overwrite a variable initialized through the command line just use this:
Set Variable %FROMINSTALLER% to 0
Set Variable %FROMINSTALLER% to 0
Does this help?
Friedrich
--
Friedrich Linder
CEO, Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 5
Re: Declaring a Variable used from Command Line
> Does this help?
Nope. :-)
> myprogram.exe /V FROMINSTALLER 1
>
> Line 1: The command line parameter set the %FROMINSTALLER% variable to 1
>
> Line 2: "1" is displayed
>
> Line 3: the script set %FROMINSTALLER% variable to 2
>
> Line 4: "2" is displayed
Here's the situation. If you remove line 3 & 4 from the script - it simply
won't compile because it says that the variable is undeclared. That's the
situation I'm in.
I think the only way around it to get it to compile is:
Line3: Set variable %FROMINSTALLER% to %FROMINSTALLER%.
At this point, I would assume that SB would allow the compile.
The issue is if you want to simply use the passed variable from the command
line, you need a SET VARIABLE somewhere in the script, otherwise, the script
won't compile. If you use a SET VARIABLE in the script, then you end up
overwriting the value passed on a command line. Thus, a Catch-22.
-Robert
Re: Declaring a Variable used from Command Line
Oh,
>> Line 1 Set Variable %FROMINSTALLER% to 0
So you are saying that even though the line says to set it to zero, it will
still equal 1.
OK, I can deal with it .... you may want to explain that in the online help
.... as to me, that seems that it is overwriting it to zero, not changing it
to one.
-Robert
Re: Declaring a Variable used from Command Line
Robert,
The Set command always happens before the command line processing, otherwise the command line would not work. ;-)
--
Russ Eggen
www.radfusion.com
Re: Declaring a Variable used from Command Line
Russ,
> The Set command always happens before the command line processing,
No it doesn't.
Run the attached with:
test /V inparm 5555
-Robert
Re: Declaring a Variable used from Command Line
Russ,
I don't know what your referring to, but I've tried this with fifty
different ways (with and without %'s, capitals, non-capitals) and I've even
moved the Set variable to the top of the script and different places. No
matter how you run this, it always says 1111.
From your comment, you make it sound simple. Maybe I just don't know
how to program (or so I've been told)
-Robert