Space should be used in front of and behind the following binary operators:
- arithmetical: *, /, % (mod), +, –, ^ (**)
- logical: & (and), | (or), @ (excluding or), =,<> (#), <, <=, >, >=
- assignment: =
a = (b + c % d) * e
No spaces are allowed in front of and behind the following unary operators:
array. Note: avoid space inside brackets (array[ 5]) to make “find” function easier.
- logical not:
- unary minus, unary plus:
Function calls should have a space in front of the opening parenthesis of the parameter list, and behind every comma separating the parameters:
abs (signedLength) minimum = min (a, 25 * b, c)
When testing equality with constants (e.g. i = 5) the constant should be the second operand.
When assigning values to Boolean variables the logical expression should be parenthesized:
bBoolValue = (i > j)
Do not use the Boolean result of logical negation of integer values or variables.
E.g. instead of if not(iIntVal) then please use if iIntVal = 0 then.
(Of course, Boolean variables and expressions can be negated, e.g. if not(bBoolVal) then).
Do not compare Boolean variables and expressions to true or false; use the value of Boolean or its negated value:
bBoolVal = 1 if bBoolVal then ! instead of: if bBoolVal = 1 ... endif if not(bBoolVal) then ! instead of: if bBoolVal = 0 ... endif
Complex expressions (e.g. where and and or are both present) should be parenthesized to clarify precedence.
Put parentheses around rarely used operator combinations.
Logical expressions consisting of many parts should be placed on multiple lines, and you should also align the sub-expressions or the logical operators:
bResult = (bValue1 & bValue3 & not(bValueWithLongerName)) | \ (not(bValue1) & not(bValue3) & bValueWithLongerName) | \ (not(bValuel2) & bValue3 & not(bValueWithLongerName)) | \ (bValue2 & not(bValue3) & bValueWithLongerName)