Math expressions in control commands
You probably know the use of math expressions in VisualNEO Win’s SetVar:
SetVar "[z]" "10" SetVar "[z]" "[z]+1"
However, math expressions can be used in e.g. the control commands If, IfEx, While, WhileEx and Loop also, resulting in shorter code. I did not find a post on this topic. So I made some examples for you and hope you’ll find these helpful:
................................................................... .Examples of math expressions in Neobook's SetVar and .control commands If, IfEx, While, WhileEx and Loop ................................................................... SetVar "[x]" "3" SetVar "[y]" "2" SetVar "[z]" "1" ................................................................... ................................................................... While "[z]" "<" "3" AlertBox "Result 1" "Value of variable z: [z]" SetVar "[z]" "[z]+1" EndWhile ...................................................................... If "[x]+[y]" ">" "[z]" AlertBox "Result 2" "[x]+[y] > [z] is TRUE" Else AlertBox "Result 2" "[x]+[y] > [z] is FALSE" EndIf ...................................................................... IfEx "[x]+[y] > [z] AND [x]-[y] = [z]" AlertBox "Result 3" "[x]+[y] > [z] AND [x]-[y] = [z] is TRUE" Else AlertBox "Result 3" "[x]+[y] > [z] AND [x]-[y] = [z] is FALSE" EndIf ...................................................................... WhileEx "[x]^2 > 0 AND [x]*[y] > 0" AlertBox "Result 4" "Value of variable x and y: [x] and [y]" SetVar "[x]" "[x]-1" SetVar "[y]" "[y]-1" EndWhile ...................................................................... .initialize [y] again because of the last example SetVar "[y]" "2" ...................................................................... If "Sqrt([y])" "<" "[z]" AlertBox "Result 5" "Sqrt([y]) < [z] is TRUE" Else AlertBox "Result 5" "Sqrt([y]) < [z] is FALSE" EndIf ...................................................................... .solving an equation for a > 0 Loop "1" "Sqr([y]+[z])" "[a]" If "[a]*[a]-3*[a]-3" "=" "[a]-3" AlertBox "Result 6" "a*a-3a-3 = a-3 is TRUE for value [a]" ExitLoop EndIf EndLoop ...................................................................... ...................................................................... . Try it yourself and use Neobook's math operators and functions: . + - * / ^ . Abs . Sin Cos Atan, . Sqr Sqrt Round Trunc
Comments
Vadim
This is useful! Thank!