BSL:Manual: Difference between revisions

8 bytes removed ,  6 December 2015
m
→‎if: wording
m (→‎var: link fix)
m (→‎if: wording)
Line 136: Line 136:
  if (7 - 8) # evaluates to true because it is non-zero
  if (7 - 8) # evaluates to true because it is non-zero


Be aware that BSL does not properly respect scope for blocks of code under "if" statements, so some actions like setting variables and using "return" will occur even if the surrounding "if" condition is false (see [[#Flow interrupt|Flow interrupt]] for an example). A workaround for setting variables conditionally is to make the variable global, and under the "if" statement call a function that modifies that variable; the function call will not fire unless the "if" condition is true.
Be aware that BSL does not always respect scope for blocks of code under "if" statements; some actions like setting variables and using "return" will occur even if the surrounding "if" condition is false (see [[#Flow interrupt|Flow interrupt]] for an example). A workaround for setting variables conditionally is to make the variable global, and under the "if" statement call a function that modifies that variable; function calls will not fire unless the "if" condition is true.


The logical operators "and" and "or" can be used to string together multiple conditions:
The logical operators "and" and "or" can be used to string together multiple conditions: