Operators

Available Operators

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulus (remainder)
  • & Bitwise AND
  • | Bitwise OR (inclusive or)
  • && Logical AND
  • || Logical OR
  • != Relational “not equal to”
  • == Relational “equal to”
  • < Relational “less than”
  • ⇐ Relational “less than or equal to”
  • > Relational “greater than”
  • >= Relational “greater than or equal to”
  • RAND A random number.
  • PIXEL The Element ID of an Pixel.
  • INGROUP Test if an element is in a group.
  • MIN will return the lower of both values
  • MAX will return the higher of both values
  • ^ Exponents
  • TAN Tangent
  • SIN Sine
  • COS Cosine
  • TAN-1 Arctangent
  • SIN-1 Arcsine
  • COS-1 Arccosine
  • SQRT Square root

Self defined Functions

A trigger can have a return value. This trigger will return the square of the first parameter:

ON square RETURN ($0 * $0)

To call this function put an asterisk in front of the triggername. For example:

SET a (*square 7)

will set a to 49.

Self defined functions should always be surrounded with parentheses. For example:

SET a (*square (*square 7))

will return (7*7)*(7*7) = 2401.

Floating Point Operations

SIN and COS are floating point operations, but BS2 doesn't have floating point variables, so you have to multiply the parameters by 1000 and devide the result by 1000. This way you get 3 decimal digits. For example “SET a (SIN 7000)” will set “a” to the sin 7 multiplied by 1000. So “a” will be 121. The real value for sin 7 would be 0,121869…

Examples

SET tutorialvar 7

will set tutorialvar to 7.

SET tutorialvar (7 * 7)

will set tutorialvar to 49.

SET tutorialvar (5 == 7)

will set tutorialvar to 0.

SET tutorialvar (5 == 5)

will set tutorialvar to 1.

SET tutorialvar (SIN 7000)

will set tutorialvar to sin(7) * 1000 = 121.

 
expressions.txt · Last modified: 2008/08/08 14:19 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki