/
PhixScript Cheat Sheet

PhixScript Cheat Sheet

Common Functions

There are over 115 functions available and these are listed in Functions, but to help you get started here is a short list of commonly used functions:

  1. Comments can be added to a single line using // or to a section using /* */.
  2. if: used where you need to evaluate a simple condition before processing an expression.
  3. ifNull: If its first value is provided then this is the returned value, else it will return the second value.
  4. switch: evaluates a set of conditions in turn, and returns the associated result for the first match.
  5. forEachIterates over an Array or Recordset and processes a script for each entry.
  6. listToStringtakes a list and returns a string delimited by a specified value e.g. comma or pipe.
  7. split: Splits a string where a separator occurs, returning a list of value as an array..
  8. contains: Used on a string will return true (1), if a string contains another specified string.
  9. listContains: Used on a list returns the position of an entry in a list (with 1 being the first item) if the value being looked for is found in the list, and false (0) otherwise.
  10. replaceAllReplace all occurrences of a pattern with a replacement string. Also, see replaceFirst.
  11. dateDiffReturn the time difference between two dates in milliseconds.
  12. dateAddAdd or subtract from a date using a specified unit e.g. _MONTH.
  13. now: Returns the current day and time, and today returns just the day.
  14. _NULL: is how to declare a null value e.g. $output = _NULL.
  15. substringReturns the portion of the supplied string between specified character positions.
  16. stringLengthReturns the length of a string.
  17. trimRemoves leading and trailing white spaces from a string, returning the cleansed string.
  18. toStringConverts a value from select data types into a string. For example, a date.
  19. toDateConverts a string in a recognised date format (e.g. 20120521 or 20120521.172108) into a date.
  20. countElements: Returns the number of elements in an Array or Recordset.

Expression Operators

The following relational operators are available:

  • ! (not; reverses the value of a logical expression)
  • && (and; can also use the attribute function and)
  • || (or; can also use the attribute function or)
  • > (greater than; can also use the attribute function gt)
  • < (less that; can also use the attribute function lt)
  • != (not equals; can also use the attribute function ne)
  • == (equals; can also use the attribute function eq)
  • >= (greater than or equal to; can also use the attribute function ge)
  • <= (less than or equal to; can also use the attribute function le)

The following arithmetic operators are available:

  • + (add; can also use the attribute function sum)
  • - (minus; can also use the attribute function sum, reversing the sign of the second operand)
  • / (divide)
  • * (multiply)

Debugging

  • debug: Adds a debug message into the System Console. This function is often used when creating a model and trying to work out why an Expression is not behaving as expected.
  • errorAdds an error message into the System Console and displays the message to the user. 

Variables

PhixFlow contains a number of Internal Variables available to PhixScript used for obtaining system and user information.

Variables in PhixFlow are declared using a $variable. The data type is implied by the first value entered, for example:

  1. $myArray  = []. Creates an array.
  2. $myString = "Hello World". Creates a string.
  3. $myDate   = toDate("20120521"). Creates a date.
  4. $myNumber = 42. Creates an integer.

Related content

Managing 4-byte Characters
Managing 4-byte Characters
Read with this
Expressions and PhixScripts
Expressions and PhixScripts
More like this
Release 11.0.0
Release 11.0.0
Read with this
Expressions and PhixScripts
Expressions and PhixScripts
More like this
Installing PhixFlow
Installing PhixFlow
Read with this
Expressions and PhixScripts
Expressions and PhixScripts
More like this