Increment numerical value in InstallAnywhere

467 views Asked by At

I have a question for those of you who have worked with InstallAnywhere:

I essentially have written a while loop in an InstallAnywhere project. What I would like to find is an easy and simple way to implement a counter inside this "While loop". Here is some pseudo code of my attempt:

Set InstallAnywhere Variable: $COUNT$ = 0
Jump Label: while
Execute Script/Batch File:
    @echo off
    set /a TEMP_NUM=$COUNT$+1 > nul
    echo %TEMP_NUM%
Set InstallAnywhere Variable: $COUNT$ = $EXECUTE_STDOUT$
Jump: while    Rule: $COUNT$ [Less Than or Equal to] 100

The above code sets $COUNT$ to the following:

Loop 0:
    1
Loop 1:
    1
Loop 2:
    1
...

I wonder if this happens because InstallAnywhere is replacing $COUNT$ inside the batch file with 0 in the first loop, and then in subsequent loops it re-uses the same batch file with $COUNT$ already substituted in (like in a batch for loop or if statement).

2

There are 2 answers

0
maciej nullpointer On

could it be that $COUNTS$ should be accessed from the OS ENV table using the special key $lax.nl.env.counts$ ? per docs,

You can access any System Environment variable (for example, access path via $lax.nl.env.path$) by specifying the property name as an all-lowercase string. These properties are resolved at application runtime, when LaunchAnywhere executes. You can also get access to System Environment variables via InstallAnywhere variables.

0
Chandrani H On

Just added some line numbers to your code:

  1. Set InstallAnywhere Variable: $COUNT$ = 0
  2. Jump Label: while
  3. Execute Script/Batch File:
  4. @echo off
  5. set /a TEMP_NUM=$COUNT$+1 > nul
  6. echo %TEMP_NUM%
  7. Set InstallAnywhere Variable: $COUNT$ = $EXECUTE_STDOUT$
  8. Jump: while Rule: $COUNT$ [Less Than or Equal to] 100

In line 5 and 6, what you are essentially doing is: echo $COUNT$+1

In line 7, you are setting COUNT to $EXECUTE_STDOUT$ ( which is usually 0, I believe? ) That would explain why it prints 1 everytime because $COUNT$ gets set to 0 at the end of each loop.