Understanding the Parser

When you type text it is either stored as text or it is converted into a number by the Parser. When you Run a function text and number Properties are retreaved, numbers are used as is, but text is passed through the Parser so that it can be Expanded or converted into a number if that is what the Function needs. Expanding text means finding embedded instructions and replacing them with usable text. Remember when text contains a number it is in the form of one character per digit or symbol.

Parser Commands $
Parser Commands in Czimps all start with a $, if you need a $ in your text type $$. The parser operates in two steps first it Expands the text then if a number is neaded it Evaluates the result.

Text Expansion
Parser commands are evaluated one at a time, the result of evaluating a Command is a text string, the Command in the original text is then replaced with this new string. When all Commands have been executed the resulting text is checked again to see if new Commands have been included in it, if so these are exicuted, and the whole process starts again. See the Parser Help page for more information.

See the Parser Help page for more information about the following commands and a few others:
$string_name includes the text from a String
${expression} inserts the result of Evaluated expression
${expression}' Evaluate expression but insert nothing
$(#table,col,row) inserts the contents of a Table cell as text
$string_store_name[index] inserts one item from a String Store
$:symbolic_expression_name converts a Symbolic to text and inserts it

Text Evaluation
If a number is needed the text is treated as a mathematical expression which is evaluated. If a number is needed but there are no commands to exicute the Expansion stage above is skipped, but Evaluation is still performed. Some Functions need to evaluate the same expression more than once in a single run, in these cases the text is converted into an internal byte code for faster repeat execution, this means that Expansion will only occur once at the start. The expression being evaluated may consist of several subexpressions seperated by commas, they are all evaluated in order but only the result of the last is used. There are many maths functions and operators, see the Parser Help and the Include Menu. There are also many non standard functions used to access other Czimps Objects, the numbers produced by these are of limited use, the functions are more valuable for their side effects.

Local Variables
A Variables value can be inserted into a calculation just by mentioning its name. If you use the name of a non existant variable a Temporary Variable is created with that named, if you do not assign anything to it its value will be the ascii code of the first letter of its name.

Vector Store Functions
These are used to access the components of vectors in a vector store. You will need to specify the handle to the store and the Vectors index number for all functions. There are two ways you cann access the components of a Vector the simplist is by quoting the absolute Component Index in getV(), insV(), repV() and remV() that is Get, Insert, Replace or Remove a Vector Component. The second method allows you to create a queue where you insert new Components at the start and remove Components further along. This is actually implimented as a circular buffer, i.e when something is removed its position can be reused. The functions controlling this are firstV(), lastV() and nextV() the action of these functions depends on the number of arguments supplied. firstV(#V,v) and lastV(#V,v) will return the current locations indexes of Vector v in store V. If these have a third index argument they set the first or last index and copy four values to _v0-3, in the caser of the last index this is relative to the first. nextV(#V,v...) Will copy 4 components to _v0-3 with _v0=the next component. If this function has more than 2 arguments the remainder are copied over Components starting at the first index and first and last are moved on appropriately. Using these Functions you can create time delays.

String Functions
The Parser has the capacity to process upto 256 strings, identified by their index numbers 0 to 255. The Ss("String_name",index) function is used to duplicate a String as a Parser String, if you change the Parser String the String Object will change too. The Cs("text",index) will set a Parser string to "text" because Parser Commands are executed before Evaluation you can put them inside the quotes in these functions. The number returned by most string functions is the Index of the result string, so one string function can be used as an argument to another. You can also assign Index numbers to Variables and use them instead. See the Parser Help for a full list of string functions.

Table Functions
The Evaluation section of the Parser has three Table functions Tget(), Tput() and T(). Tget() and Tput get or replace a Table Cell in/with a Parser String. The T() function compares two Table Cells, it returns -1 for less or before, 0 for equal to or vthe same as, and 1 for greater than or after, before and after mean if sorted alphabetically. If you need to evaluate a Table Cell as an expression use $().

Image Functions
The R... and L... Image functions just get a pixel from the active Left or Right Image. L(0), R(0), L(1) and R(1) return the points chosen by the user in the corresponding Image Windows 0 is the Active Point and 1 the Previous Active Point. The I... family of functions are used to get or set various Pixel Components.

Matrix Functions
The X... family of functions allow you to get or set upto the first four Components from a Matcell. In addition you can initialize/clear a Matrix see the Parser Help for more details.

Map Functions
The M... family of functions allow you to work with Mapcells in a similar way to Pixels and Matcells above, the get function will load a Mapvec of upto 4 Components. In addition There are various test and utility functions see the Parser Help.

Focus Functions
Allow acces to the Focus point in Images, Maps and Matrices, even when they are not displayed in an Image Window.

Symbolics Functions
The G... functions work on Symbolic Expressions, there are a large number of functions that test Symbolics listed in the Parser Help. You will need to create a Handle to each expression you wish to use in this way, or select it and use #_G. Gs() will return a Symbolic as a Parser String. G() is used to evaluate a Symbolic to a floating point number. There is a mechanism for substituting numbers for Symbols, first you need the names of the Symbols storing in consecutive Parser Strings, then you can use Gs(#Exp,index,...) to evaluate Exp substituting for Symbols starting at index with values in the same order as the Symbols.

Object Property Functions
Ow(#object) and Oh(#objec) return the Width and Height of Objects where this is relavent. Oc(#object) is the number of child items in a List or Collection. Opos(#object) returns an objects position amongst its siblings. Otype(#object) returns a unique number for each type of Object use this in conjunction with Ovalid(#object,type) to discover if an object is still valid, Czimps reuses Handle Numbers so you cannot simply test a Handle.

Button Functions
There are 12 buttons on the Running Dialog you can get/set whether they are pressed with the B... functions. Numbering starts at the upper left with button zero, and finishes at the lower right with button 11.

Live Object Functions
The V... and K... families of functions give access to the current state values of Live Objects. The K... functions are VTK only, Kp... and Kc... refer to Points and Cells, Kf... and Kg... are used to evaluate VTK Functions, and the ijk suffix means that each Cell/Point is accesed with three indices. The V... functions allow you to make various settings and queeries while these functions are Running, upto 4 values can be got or set, see the individual Live Functions help files for more details.