Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Declaring a Variable used from Command Line

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default 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

  2. #2

    Default 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

  3. #3

    Default 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

  4. #4

    Default 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

  5. #5

    Default 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

  6. #6

    Default 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

  7. #7

    Default 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

  8. #8

    Default 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

  9. #9

    Default 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

  10. #10

    Default 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Set Variable - Bitwise OR
    By LoboMgr in forum SetupBuilder 'How Do I' Questions
    Replies: 1
    Last Post: 06-07-2006, 11:09 AM
  2. #00015: Is there a system PATH Environment Variable Size Limit in XP?
    By FAQ in forum SetupBuilder FAQs, Tips and Techniques
    Replies: 0
    Last Post: 04-03-2006, 07:42 AM
  3. #00011: How do I add directories to the PATH system environment variable?
    By FAQ in forum SetupBuilder FAQs, Tips and Techniques
    Replies: 0
    Last Post: 02-08-2006, 01:17 AM
  4. Using a variable in Install Files
    By NewsArchive in forum SetupBuilder - NNTP
    Replies: 11
    Last Post: 01-24-2006, 01:30 AM
  5. Cannot open and compress service file - error
    By NewsArchive in forum SetupBuilder - NNTP
    Replies: 6
    Last Post: 12-06-2005, 04:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •