The conditional instruction !if-!then-!else allows for operation of other statement depending if the result was true (0 or less) or false ( greater than 0).
As MPJ is a line-processing environment, the condition and statements must be contained on a single line in the format of:
!if condition !then trueStatement(s)
or
!if condition !then trueStatement(s) !else falseStatement(s)
The condition can be any standard math operation (Braces not required). Typically they are equalities such as:
[ain0] > 10 [txtResult] = 50 // == may be used [din0] and [din1] // && or & may be used
([ain1] > 10) and ([ain1] < 20)
A good way to test an expression is using the Debug/CLI to ensure it is properly formatted math operation, such as the following and view the result ensuring it gives 1 or 0 without errors. ? { (1==1) && (1==2) }
Strings may be evaluated using post-fix math operations, {:: } required, if parameters have spaces, a :: is required between each element of it. ? {:: test test equals}
? {:: test me::test me::equals}
The !then portion can be a single statement or multiple statements separated by semi-colons. The !then portion runs if the result is true.
!if 1=1 !then !bell
!if 1=1 !then !bell; ? It's true!
The !else portion, which is optional, if the condition is false and multiple statements can be performed: !if 1=2 !then !bell !else ? It's false
!if 1=2 !then !bell; ? It's true! !else ? It's false; ? Try again
If a large a number of operations need to be performed, a macro file can be written and called, or the event code of a hidden control can be ran which holds the statements to be performed.
!if 1=1 !then !runMacro myTest.txt !if 1=1 !then !btnTest.run
|