Multiple operators are now supported

Multiple operators are now supported

The Simple Macro Maker now also supports multiple operators. That means that one can use more than one operator in for example arithmetical or boolean expressions. This was accomplished by splitting the expressions into binary trees and then letting each node perform a single operator with the childrens' values.

Example:

<for iterations="5">
    <wait base="500" random="0"/>
    <print>$Counter*$Counter+1</print>
    <set_variable>
        <set_variable-name>Counter</set_variable-name>
        <set_variable-value>$Counter+2*5</set_variable-value>
    </set_variable>
</for>
Will now output: 2 122 442 962

1682

Before the program would have evaluated one operator and then tried to evaluate the values around it (which would make the example raise an error).

This is a picture to try to illustrate how the binary tree works. This tree evaluates the expression "4*3+2/1-2+6":

smm_news2.jpg

The root node then calls the two children nodes for their values, they call their children and so on. In the end the tree will have been evaluated from the bottom to the top. The priorities of different operations (/, *, -, + is highest priority to lowest) are reflected in that the operations with the highest priorities are placed as low as possible on the tree (as far away from the root as possible).