PDA

View Full Version : Declaring a Variable used from Command Line



NewsArchive
01-10-2006, 02:06 AM
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

NewsArchive
01-10-2006, 02:06 AM
Hello,

The only workaround I found was to use _SB_PARAM1 instead of my own
variable.

Is that correct?

-Robert

NewsArchive
01-10-2006, 02:06 AM
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

NewsArchive
01-10-2006, 06:38 AM
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

NewsArchive
01-10-2006, 06:38 AM
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

NewsArchive
01-10-2006, 09:22 AM
> 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

NewsArchive
01-10-2006, 09:22 AM
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

NewsArchive
01-10-2006, 09:23 AM
Robert,

The Set command always happens before the command line processing, otherwise the command line would not work. ;-)

--
Russ Eggen
www.radfusion.com

NewsArchive
01-10-2006, 09:23 AM
Russ,

> The Set command always happens before the command line processing,

No it doesn't.

Run the attached with:

test /V inparm 5555

-Robert

NewsArchive
01-10-2006, 09:24 AM
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

NewsArchive
01-10-2006, 09:24 AM
Ahh ... the "V" is the case-sensitive part.

If the "V" is capital, then it seems to work.

-Robert

NewsArchive
01-10-2006, 09:24 AM
The variable (and the command line switch) are case sensitive!

So it should read:

test /V INPARM 5555

Friedrich

NewsArchive
01-10-2006, 09:24 AM
A command line process cannot "declare" a variable. You have to declare
the variable in your script before you can use it. Otherwise, the
compiler would display a "variable not defined" error.

If you pass a value to a variable through the command line, the first
"Set Variable" item (it's the item that declares the variable) sets the
variable to the "command line" value.

If no value is passed through the command line, the "original" Set Variable
item value is used.

Does this make sense?

BTW, I'll explain this in the docs.

Friedrich

NewsArchive
01-10-2006, 09:30 AM
Yep! That Explains It! :-)

Thank you again for your excellent work.

-Robert

NewsArchive
01-10-2006, 09:30 AM
Hello,

Yes - that makes a whole bunch of sense when explained. In the
documentation, it should explain that the SET command will set the value to
the COMMAND LINE VALUE if it exists rather than the value that you set.

Then, it should explain that you don't need the %'s in the VARIABLE names -
and that everything is CASE-SENSITIVE. :-)

Then, I won't be a pain in the ass. <laugh>

Thank you!!!

-Robert

NewsArchive
01-10-2006, 09:30 AM
:)

I agree. My documentation is suboptimal in this case. I'll change/improve
it.

Thanks,
Friedrich

NewsArchive
01-10-2006, 11:18 AM
Hi Friedrich,

>The variable (and the command line switch) are case sensitive!

Could that be changed? I can see where I (and many others) would get
into trouble with case sensitive cl...

Best regards,

Arnór Baldvinsson
Icetips Software
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
01-10-2006, 11:18 AM
Arnór,

Done. Both command line switches and variable names are not case-sensitive any longer.

Thanks,
Friedrich

--
Friedrich Linder
CEO, Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 5

NewsArchive
01-11-2006, 01:37 AM
Thank you!

It works much better this way as you can't ensure that the users are going
to do things in upper-case.

-Robert

NewsArchive
01-11-2006, 01:38 AM
Must resist..... <seg>

Sounds like you got it sorted. ;-)

--
Russ Eggen
www.radfusion.com

NewsArchive
01-19-2006, 10:41 AM
> Done. Both command line switches and variable names are not
> case-sensitive any longer.

Brilliant - I lost about 2 hours last night before reading this on the NG -
this is a good one for future users.

--
Geoff

Capesoft - taking you higher and further

www.capesoft.com

NewsArchive
01-19-2006, 10:41 AM
We'll make SetupBuilder 5.3 available later today (supports Clarion 6.3).

Friedrich