Expressions

From ADRIFT 5 Manual Wiki
Revision as of 03:58, 13 October 2011 by Saabie (Talk | contribs) (Created page with "Expressions are used to calculate integer values or produce strings of text that can then be stored in Variables or Properties using Actions, or used in comparison op...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Expressions are used to calculate integer values or produce strings of text that can then be stored in Variables or Properties using Actions, or used in comparison operations in Restrictions.


Integer Functions

  • sInstr()
  • sMID()
  • min(x,y) Returns the minimum of value x and y
  • max(x,y) Returns the maximum of value x and y
  • either(x,y) Randomly returns either x or y
  • rand(x,y) Selects a random value between x and y
  • abs(x) Returns the absolute value of x( the magnitude regardless of sign), i.e. abs(-4) = 4
  • MOD()

x mod y Returns the modulus of x and y, i.e. the remainder when x is divided by y. i.e. 11 mod 4 = 3

  • If(test,x,y)

If "test" evaluates true, returns x, else returns y Where "test" is a=b, a==b, a<b, a<=b, a>b, a>=b, a<>b, a!=b and conditions can be ANDed using "and", "&" or "&&" or ORed using "or", "|", "||" IF(%variable1%=1,%variable2%+1,RAND(5,7))

  • instr(text, search) Returns the position of <search> within <text>

i.e. instr(“hello”,”e”) = 2

  • len(text) Returns the length of <text>
  • val(text) Converts <text> to a number (or zero if it can't match)

String Functions

text & text text + text Appends two strings together LEN()

  • ucase(text) Converts <text> to upper case
  • lcase(text) Converts <text> to lower case
  • pcase(text) Converts <text> to proper case, i.e. a capitalises the first

letter of each word, with the rest in lower case

  • left(text, length) Returns the <length> leftmost characters of <text>
  • right(text, length) Returns the <length> rightmost characters of <text>
  • mid(text, start, length) returns <length> characters of <text>, starting at <start>
  • str(x) Converts an integer value x to text form