Announcement

Collapse
No announcement yet.

Packages and If Statements

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Packages and If Statements

    I have a project with 24 packages in it, each package consists of a single exe, and they're installed by means of two Select Packages screens, 12 on each.

    What I need to do if before installing, close any copies of the programs they have running already, and after installing set a reg key, and run any they chose to install.

    And so, IF statements checking to see if the package variables are true or false seemed logical.

    I set up two Show Message dialogs that displayed the current values of the 24 package variables... and it correctly displays TRUE for the ones that were selected for installation, and FALSE for those that weren't. But when I try to use an IF statement on the variable, it fails.

    So I made a test project with only two packages. Chose to install one, and not the other. Displaying the two vars with a Show Message shows TRUE for the first and FALSE for the second. SO I set up a bunch of if statements to see which would trigger and which wouldn't. I tested both tosee if they equalled true, True, TRUE, "true", "True", "TRUE", false, False, FALSE, "false", "False", "FALSE", 0, and <> 0... and <> 0 triggers on both of them whenever they're true or false, and *NONE* of the other fired.

    Can someone explain this? How is it when I print the two vars it correctly shows them as being TRUE and FALSE, but I can't seem to use any kind of IF statement on them and have them work.

  • #2
    Re: Packages and If Statements

    What version of Setup Factory?

    What's the whole expression?
    --[[ Indigo Rose Software Developer ]]

    Comment


    • #3
      Re: Packages and If Statements

      Also: where are you putting the actions? (Which action tab?)
      --[[ Indigo Rose Software Developer ]]

      Comment


      • #4
        Re: Packages and If Statements

        6.0.1.0 updated today, running on WinXP Pro.

        Currently in Before Installing which is after I make the selection of which packages to install.

        The current contents of the Before Installing Section are...

        ========

        Show Message Box (Admin %L-ADMIN%)
        IF (%L-ADMIN% = true)
        Show Message Box (true)
        END IF
        IF (%L-ADMIN% = True)
        Show Message Box (True)
        END IF
        IF (%L-ADMIN% = TRUE)
        Show Message Box (TRUE)
        END IF
        IF (%L-ADMIN% = "true")
        Show Message Box ("true" with quotes)
        END IF
        IF (%L-ADMIN% = "True")
        Show Message Box ("True" with quotes)
        END IF
        IF (%L-ADMIN% = "TRUE")
        Show Message Box ("TRUE" with quotes)
        END IF
        IF (%L-ADMIN% = false)
        Show Message Box (false)
        END IF
        IF (%L-ADMIN% = False)
        Show Message Box (False)
        END IF
        IF (%L-ADMIN% = FALSE)
        Show Message Box (FALSE)
        END IF
        IF (%L-ADMIN% = "false")
        Show Message Box ("false" with quotes)
        END IF
        IF (%L-ADMIN% = "False")
        Show Message Box ("False" with quotes)
        END IF
        IF (%L-ADMIN% = "FALSE")
        Show Message Box ("FALSE" with quotes)
        END IF
        IF (%L-ADMIN% = 0)
        Show Message Box (= 0)
        END IF
        IF (%L-ADMIN% <> 0)
        Show Message Box (<> 0)
        END IF
        Show Message Box (ADS %L-ADS%)
        IF (%L-ADS% = true)
        Show Message Box (true)
        END IF
        IF (%L-ADS% = True)
        Show Message Box (True)
        END IF
        IF (%L-ADS% = TRUE)
        Show Message Box (TRUE)
        END IF
        IF (%L-ADS% = "true")
        Show Message Box ("true" with quotes)
        END IF
        IF (%L-ADS% = "True")
        Show Message Box ("True" with quotes)
        END IF
        IF (%L-ADS% = "TRUE")
        Show Message Box ("TRUE" with quotes)
        END IF
        IF (%L-ADS% = false)
        Show Message Box (false)
        END IF
        IF (%L-ADS% = False)
        Show Message Box (False)
        END IF
        IF (%L-ADS% = FALSE)
        Show Message Box (FALSE)
        END IF
        IF (%L-ADS% = "false")
        Show Message Box ("false" with quotes)
        END IF
        IF (%L-ADS% = "False")
        Show Message Box ("False" with quotes)
        END IF
        IF (%L-ADS% = "FALSE")
        Show Message Box ("FALSE" with quotes)
        END IF
        IF (%L-ADS% = 0)
        Show Message Box (= 0)
        END IF
        IF (%L-ADS% <> 0)
        Show Message Box (<> 0)
        END IF

        ========

        The very first Message Box showing the value of %L-ADMIN% displays "Admin TRUE", then none of the IF statements fire until <> 0, then it displays the Message Box for %L-ADS%, which is "ADS FALSE", and then none of the second set of IF statements fire until <> 0 again.

        What is the proper way to test boolean values? The examples in the User Guide mention using the words true and false, but never showan example that I've seen, just number examples.

        What am I doing wrong? :P

        Comment


        • #5
          Re: Packages and If Statements

          Aha. The problem is in your variable names.

          Those hyphens in your variable names are being seen as subtraction operators in these expressions.

          So,

          %L-ADMIN% = "TRUE"

          ...isn't testing whether %L-ADMIN% contains "TRUE", but rather, whether the string "ADMIN%" subtracted from the string "%L" is true. This is essentially the same as if you wrote:

          "%L" - "ADMIN%" = "TRUE"

          The "-" character is an operator, which also makes it a value-delimiting character.

          You have two options...you can either surround your variable names with quotes, like so:

          "%L-ADMIN%" = "TRUE"

          ...or, you can replace the hyphen with a more appropriate character, like an underscore (which is safe), like so:

          %L_ADMIN% = "TRUE"

          --[[ Indigo Rose Software Developer ]]

          Comment

          Working...
          X