From ftm
Jump to: navigation, search
(Values and Lists)
(Values and Lists)
Line 11: Line 11:
 
They values can be represended by the following terms:
 
They values can be represended by the following terms:
 
* a '''''simple''''' value (int, float, symbol) such as '1', '2.3' and 'three'
 
* a '''''simple''''' value (int, float, symbol) such as '1', '2.3' and 'three'
* a '''''named''''' value such as $myobj
+
* a '''''named''''' value such as '$myobj'
 
* an '''''element''''' of an object such as '$myobj[7]'
 
* an '''''element''''' of an object such as '$myobj[7]'
* a numberd '''''argument''''' such as '$1'
+
* a numbered '''''argument''''' such as '$1', '$2', etc.
  
 
Examples of '''''simple''''' values are:
 
Examples of '''''simple''''' values are:
Line 36: Line 36:
 
* $mydict[x]
 
* $mydict[x]
  
Anything more complex than $-names and []-elements has to happen within parenthesis (see below).
+
Numbered arguments are useful in the FTM message box and can be used in the ''expr'' object , but they give error in expressions of FTM definitions with ''ftm.object''.
 +
 
 +
Operators other than '$' and '['/']' are not evaluated outside of parentheses (see below).
  
 
Single values can be concatenated to '''''argument lists''''' (in the message box ''lists'' or ''messages'') with spaces like:
 
Single values can be concatenated to '''''argument lists''''' (in the message box ''lists'' or ''messages'') with spaces like:
Line 43: Line 45:
 
* $myobj set 7 9.8 ten
 
* $myobj set 7 9.8 ten
  
Argument lists within parenthesis will be evaluated (see below).
+
Argument lists within parentheses will be evaluated (see below).
 
 
Numbered arguments are useful in the FTM message box and can be used in the ''expr'' object , but they give error in expressions of FTM definitions with ''ftm.object''.
 
  
 
== Parenthesis ==
 
== Parenthesis ==

Revision as of 14:35, 6 June 2007

FTM expressions are used in the following contexts

  • the FTM message box (ftm.mess)
  • FTM definitions (ftm.object)
  • the expr class/object

The syntax is basically always the same appart from minor context dependent details.

Values and Lists

The values of FTM expressions can be int, float, symbol or references to FTM object. They values can be represended by the following terms:

  • a simple value (int, float, symbol) such as '1', '2.3' and 'three'
  • a named value such as '$myobj'
  • an element of an object such as '$myobj[7]'
  • a numbered argument such as '$1', '$2', etc.

Examples of simple values are:

  • 1 ... an int
  • -2 ... an int
  • 2.3 ... a float
  • -4. ... a loat
  • 5.67e-4 ... a float
  • .89 ... a float
  • ten ... a symbol
  • 11-12 ... a symbol (because no space!)
  • -thirteen ... a symbol

Named values are defined by FTM definitions using ftm.object. The names, always representing a single value, are used in expressions with a leading dollar – '$' – making for example:

  • $x
  • $myobject

An element of an object can be accessed with FTM expressions using brackets – '[' and ']', for example:

  • $myvec[0]
  • $mymat[0 0]
  • $mydict[x]

Numbered arguments are useful in the FTM message box and can be used in the expr object , but they give error in expressions of FTM definitions with ftm.object.

Operators other than '$' and '['/']' are not evaluated outside of parentheses (see below).

Single values can be concatenated to argument lists (in the message box lists or messages) with spaces like:

  • 1 2.3 three
  • 4 + 5.5 / six (this is a list of 5 elements)
  • $myobj set 7 9.8 ten

Argument lists within parentheses will be evaluated (see below).

Parenthesis

Parenthesis in FTM expressions – '(' and ')' – always will (try to) evaluate the contained elements to a single value.

Inside parenthesis you'd have either one

  • a value such as '(1)' or '($x)' or '($mydict[x])' (in which case the parenthesis are useless)
  • an infix expression such as '(4 + 5.5 / $six)'
  • a prefix expression such '(random -90 0)' or '($myobj set 7 9.8 ten)'