Planimate Expression Language
Previous versions of Planimate referenced data using a dialog based selector. This has been augmented with an underlying textual expression language which enables more straightforward mathematical, boolean and string manipulation.
The following lists the operators and types available in an expression. They are listed in order of precedence - the higher ones in the list will evaluate before the lower ones (BODMAS rules are followed).
|reference||Attribute/cell/row/column/label reference, references data in a model|
|"string"||Quoted text string|
|'x'||Single ASCII character|
|ref.prop||Property of a referenced datum|
|[...]||Index property for tables and lists|
|||Denotes an entire item table reference|
|function()||Internal expression function|
|ref.func()||Property function of a referenced datum|
|!||Logical NOT, !1=0, !123=0, !0=1|
|<||Logical less than|
|<=||Logical less than or equal|
|>||Logical greater than|
|>=||Logical greater than or equal|
|==||Logical equal (values follow PL's equality check rules)|
|!=||Logical not equal|
|^||Logical exclusive-or 0^0=0, 0^1=1, 1^0=1, 1^1=0|
|,||Comma separator for parameters to functions|
Brackets () can be used to force order, eg: (a + b) * c
As well as the operators above, a number of functions can be used. These can be nested and are particularly useful for complex math and string manipulation.
The most useful ability of expressions is the ability to reference data within a Planimate model. Typically such a reference has a type letter, followed by a period then the datum's name.
Most operations expect numeric data. Some expect entire table rows, tables, columns, label lists or text strings. In case where text is needed, Planimate will automatically translate values to their textual form following the format of the container of the value. The $= operation will translate text strings into the format of the container (as well it can) if its not a text format.
|i.attribute||Value||Item||Attribute defined for an item class but uniquely settable for each|
|p.attribute||Value / Text||Subsystem||Attribute defined and only visible within a subsystem and the portal/subsystems contained therein.|
|r.attribute||Value / Text||Routine (Change)||Attribute defined within a routine (or subroutine). String attributes are not recursive within subroutines that call themselves but values are.|
|s.attname||Value / Text||System wide||System provided access to properties and settings of the runtime environment|
|b.name||Value||Global||Enables a labelled constant to be used instead of 0 or 1. 'name' can be FALSE, NO or OFF for 0 and TRUE, YES or ON for 1. This can help make code intent clearer without any impact on performance in looking up a normal attribute or label value.|
|t.tablename[r][c]||Value / Text||Subsystem||References a table cell. 'c' can be a column label for the table, such as 'c.Origin' or an index.|
|t.tablename||Table||Subsystem||Reference to an entire table|
|t.tablename.Row(value)||Row||Subsystem||Reference to an entire table row|
|t.tablename.Column(value)||Column||Subsystem||Reference to an entire table column|
|Row||Subsystem||Reference to an entire table row determined by search for a 'key' in column 'keyc'|
|Value / Text||Subsystem||Reference to a table cell determined by search for a 'key' in column 'keycl'. Once the row is found the cell is taken from column 'c'.|
|Value||Subsystem||The row number determined by search for a 'key' in column 'keyc'|
|t.tablename.Remap(x,yc)||Value||Subsystem||Lookup and interpolation of value from column 'ycl' based on the row(s) which bound value 'x' in column 1 of the table.|
|t.table[r][c].Property||Value||Subsystem||Converts a cell reference at [r][c] so it references the cell colour property data which enables the cells background and foreground colours to be individually set.|
|t.Dynamic(usename)||Table||Subsystem||Enables a table to be referenced by name dynamically. 'usename' is interpreted as a string to name the table. Note that matched references cannot be used with this kind of table reference.|
|t.tablename.RowCount||Value||Subsystem||References the number of rows in the table|
|t.tablename.ColumnCount||Value||Subsystem||References the number of columns in the table|
|Value||Subsystem||Resolves the index of column 'label' in the table.|
|Table||Item||Enables access to an item table reference which can be dynamically associated with a table in the model and carried to another part of the model by the item, where that table may not be in scope.|
||Resolves the numerical index associated with text 'label' in the label list 'labellistname'.|
||Resolves the numerical index associated with a label in 'labellistname' where 'value' counts labels starting at 1 for the first.|
|l.labellistname||LabelList||Subsystem||Enables a reference to an entire label list where such a reference is required. Note that any other reference involving a label list, either explicitly (like l._colors["black"]) or implicitly, (like p.portalatt where portalatt is formatted for a label list) can be used where a list reference is expected.|
|s.item||Entire item||Item||References an entire item. Normally items are implicit and do not need to be referenced for an interaction but this is provided for special item properties.|
|s.item.Carried(ind,name)||Value||Item||References an attribue 'name' on an item being carried by the current item. 'ind' specifies which item, it can be a number like 1 for the first item, s.ItemsCarried uses the system attribute to get the last item picked up or i.CARRYINDEX enables use of a modeller created attribute which must be named CARRYINDEX to determine which carried item the reference will refer to.|
|(ref).ObjectProperty||Value||Object||Interprets the value of 'ref' as an object index and returns object property 'objectproperty' for that object, eg: p.fromportal.ObjectXPosition would retrieve the co-ordinate for the portal object referenced by a portal attribute 'fromportal'.|
Attribute/table/list names must be quoted if they contain spaces or characters apart from letters, numbers and underscore. Future versions will remove support for names with characters needing quotes so update older models accordingly.
Expressions are "parsed" when OK is clicked so any syntax errors will be picked up during editing. However attribute names, table columns and label lookups are not verified until runtime.