I am trying to create a counter. Seems straightforward, you just add 1, yet every time I try, I get "Error in Math Expression". I set a variable in a while loop called ${loop_minutes} with a value of 0, for the Action, I want to add 1, I have tried the following: ${loop_minutes}=${loop_minutes}+1 ${loop_minutes}=${loop_minutes+1} ${loop_minutes}=${loop_minutes}+"1" ${loop_minutes}=${loop_minutes + "1"} How do I increment the counter?

asked 02 Sep '13, 23:26

GSimpson's gravatar image

GSimpson
1223
accept rate: 0%


you can just use:

<setInstallerVariable>
    <name>loop_minutes</name>
    <value>0</value>
</setInstallerVariable>
<mathExpression>
    <text>${loop_minutes}+1</text>
    <variable>loop_minutes</variable>
</mathExpression>
link

answered 03 Sep '13, 03:46

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

The error that I am getting is the following:
Error executing action {mathExpression}:
Error in math expression

Since there is only 1 mathExpression in the entire installer, it is obvious that this is it. So, how do I increment "loop_minutes"?

The code that I am using is:

<while>
<actionList>
    <mathExpression>
        <text>${loop_minutes}+1</text>
        <variable>loop_minutes</variable>
    </mathExpression>
    <if>
        <actionList>
            <addTextToFile>
                <file>${prefix}/backup/dailybackup.sql</file>
                <text>t,</text>
            </addTextToFile>
        </actionList>
        <conditionRuleList>
            <compareValues>
                <logic>equals</logic>
                <value1>${dailystartmin}</value1>
                <value2>${loop_minutes}</value2>
            </compareValues>
        </conditionRuleList>
        <elseActionList>
            <addTextToFile>
                <file>${prefix}/backup/dailybackup.sql</file>
                <text>f,</text>
            </addTextToFile>
        </elseActionList>
    </if>
</actionList>
<conditionRuleList>
    <compareValues>
        <logic>less</logic>
        <value1>${minutes}</value1>
        <value2>60</value2>
    </compareValues>
</conditionRuleList>
</while>
link

answered 04 Sep '13, 23:58

GSimpson's gravatar image

GSimpson
1223
accept rate: 0%

I think I see something here... It would make sense, kind of... The following are debugger log files.

This is where I set the variables.

No rules provided, returning 'true'
Rules match
Action <setInstallerVariable> was properly executed
Considering <setInstallerVariable> action
Properties of element <setInstallerVariable>:
<abortOnError> : "1" -> "1"
<breakpoint> : "0" -> "0"
<customErrorMessage> : "" -> ""
<explanation> : "" -> ""
<name> : "${loop_minutes}" -> "***unknown variable loop_minutes***"
<persist> : "0" -> "0"
<progressText> : "" -> ""
<ruleEvaluationLogic> : "and" -> "and"
<run> : "1" -> "1"
<show> : "1" -> "1"
<showMessageOnError> : "1" -> "1"
<value> : "0" -> "0"

Here is where the variables get manipulated...

Evaluating rule <compareValues>
Result is '1'
No more rules to execute
Rules are true
Executing <actionList>
Considering <mathExpression> action
Properties of element <mathExpression>:
<abortOnError> : "1" -> "1"
<breakpoint> : "0" -> "0"
<customErrorMessage> : "" -> ""
<explanation> : "" -> ""
<progressText> : "" -> ""
<ruleEvaluationLogic> : "and" -> "and"
<run> : "1" -> "1"
<show> : "1" -> "1"
<showMessageOnError> : "1" -> "1"
<text> : "${loop_minutes}+1" -> "***unknown variable loop_minutes***+1"
<variable> : "loop_minutes" -> "loop_minutes"
Rules are true
Executing <actionList>
Considering <mathExpression> action
Properties of element <mathExpression>:
<abortOnError> : "1" -> "1"
<breakpoint> : "0" -> "0"
<customErrorMessage> : "" -> ""
<explanation> : "" -> ""
<progressText> : "" -> ""
<ruleEvaluationLogic> : "and" -> "and"
<run> : "1" -> "1"
<show> : "1" -> "1"
<showMessageOnError> : "1" -> "1"
<text> : "${loop_minutes}+1" -> "***unknown variable loop_minutes***+1"
<variable> : "loop_minutes" -> "loop_minutes"

Now, the question becomes, What is an unknown variable and why is it messing with me? :)

link

answered 05 Sep '13, 00:25

GSimpson's gravatar image

GSimpson
1223
accept rate: 0%

edited 05 Sep '13, 00:35

Where do you define that installer variable "loop_minutes"? Obviously, it is unknown inside the actionList that executes the <mathExpression>.

Your should move the installer variable to the correct scope so the math expressions knows about it. If you cannot move the <setInstallerVariable> action, you might want to make the variable global using the <globalVariables> action (see http://installbuilder.bitrock.com/docs/installbuilder-userguide.html#globalVariables).

(05 Sep '13, 03:04) Dirk Stegemann

Variables on InstallBuilder must be defined before you access their values. As it is used in the <mathExpression> to increment its value, it must be initialized to 0 so the first time it is properly solved. In your case, just insert the below code right before the <while> action:

<setInstallerVariable>
    <name>loop_minutes</name>
    <value>0</value>
</setInstallerVariable>
(05 Sep '13, 03:15) juanjo ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×41
×14
×3
×3
×1

Asked: 02 Sep '13, 23:26

Seen: 1,499 times

Last updated: 05 Sep '13, 03:15