CLIP() | Evaluate function. |
COMPILEFILE() | Compile file. |
COMPILESTRING() | Compile string. |
ERRORBLOCK() | Post a code block to execute when a runtime error occurs |
EVAL() | Evaluate a code block |
FIELDBLOCK() | Return a set-get code block for a given field |
FIELDWBLOCK() | Return a set-get code block for a field in a given work area |
LOAD() | Load byte-code file or dynamic library. |
LOADBLOCK() | Load byte-code file. |
MEMVARBLOCK() | Return a set-get code block for a given memory variable |
START() | Start task. |
CLIP(<sFuncName>, [<Param1>, ..., <ParamN>) --> <vData>
Returns the result of evaluate <sFuncName> function.
CLIP() evaluates function with name <sFuncName> and returns result this function.
CLIP("substr","asdfghjkl",2,3) // --> "sdf"
No dependies of platform.
EVAL(<bBlock>, [<BlockArg list>]) --> LastBlockValue
EVAL() returns the value of the last expression within the block. A code block can return a value of any type.
EVAL() is a code block function. It is the most basic code block evaluation facility in the xClipper system. A code block is a special data value that refers to a piece of compiled program code. For more information on code blocks, refer to the "Basic Concepts" chapter in the Programming and Utilities Guide.
To execute or evaluate a code block, call EVAL() with the block value and any parameters. The parameters are supplied to the block when it is executed. Code blocks may be a series of expressions separated by commas. When a code block is evaluated, the returned value is the value of the last expression in the block.
The xClipper compiler usually compiles a code block at compile time. There are, however, occasions at runtime when you may need to compile a code block from a character string. You can do this by using the macro operator (&).
EVAL() is often used to create iteration functions. These are functions that apply a block to each member of a data structure. AEVAL(), ASORT(), ASCAN(), and DBEVAL() are iteration functions (e.g., AEVAL() applies a block to each element within an array).
This example creates a code block that increments a number, and then evaluates it: bBlock := { |nArg| nArg + 1 } ? EVAL(bBlock, 1) // Result: 2 This example demonstrates compiling a code block at runtime using the macro operator (&): // Compile a string to a block bBlock := &("{ |nArg| nArg + 1 }") // Evaluate the block ? EVAL(bBlock, 1) // Result: 2
FIELDBLOCK(<cFieldName>) --> bFieldBlock
FIELDBLOCK() returns a code block that, when evaluated, sets (assigns) or gets (retrieves) the value of the given field. If <cFieldName> does not exist in the specified work area, FIELDBLOCK() returns an empty block.
FIELDBLOCK() is a database function that builds a code block. When executed with an argument, the code block created by this function assigns the value of the argument to <cFieldName>. When executed without an argument, the code block retrieves the value of <cFieldName>.
Note that the specified field variable may not exist when the code block is created, but must exist before the code block is executed.
This example compares FIELDBLOCK() to a code block created using the macro operator. Note that using FIELDBLOCK() avoids the speed and size overhead of the macro operator: // Set-Get block defined using macro operator bSetGet := &( "{ |setVal| IF( setVal == NIL,; FName, FName := setVal ) }" ) // Set-Get block defined using FIELDBLOCK() // bSetGet created here is the functional // equivalent of bSetGet above bSetGet := FIELDBLOCK("FName")
FIELDWBLOCK(<cFieldName>, <nWorkArea>) --> bFieldWBlock
FIELDWBLOCK() returns a code block that, when evaluated, sets (assigns) or gets (retrieves) the value of <cFieldName> in the work area designated by <nWorkArea>. If <cFieldName> does not exist in the specified work area, FIELDWBLOCK() returns an empty block.
FIELDWBLOCK() is a database function that builds a code block. When evaluated with the EVAL() function, the code block first selects the designated <nWorkArea>. If an argument was passed, the code block then assigns the value of the argument to <cFieldName>. If no argument was passed, the code block retrieves the value of <cFieldName>. The original work area is then reselected before the code block returns control.
Note that the specified field variable may not exist when the code block is created but must exist before the code block is executed.
This example compares FIELDWBLOCK() to a code block created using the macro operator. Note that using FIELDWBLOCK() avoids the speed and size overhead of the macro operator: // Set-Get block for work area 1 defined with // macro operator bSetGet := &( "{ |setVal| IF( setVal == NIL, ; 1->FName, 1->FName := setVal ) }" ) // Set-Get block defined using FIELDWBLOCK() // bSetGet created here is the functional // equivalent of bSetGet above bSetGet := FIELDWBLOCK("FName", 1)
MEMVARBLOCK(<cMemvarName>) --> bMemvarBlock
MEMVARBLOCK() returns a code block that when evaluated sets (assigns) or gets (retrieves) the value of the given memory variable. If <cMemvarName> does not exist, MEMVARBLOCK() returns NIL.
The code block created by MEMVARBLOCK() has two operations depending on whether an argument is passed to the code block when it is evaluated. If evaluated with an argument, it assigns the value of the argument to <cMemvarName>. If evaluated without an argument, the code block retrieves the value of <cMemvarName>.
This example compares MEMVARBLOCK() to a code block created using the macro operator (&). Note that using MEMVARBLOCK() allows you to avoid the speed and size overhead of the macro operator: PRIVATE var := "This is a string" // // Set-Get block defined using macro operator bSetGet := &( "{ |setVal|; IF( setVal == NIL, var, var := setVal ) }" ) // Set-Get block defined using MEMVARBLOCK() // bSetGet created here is the functional // equivalent of bSetGet above bSetGet := MEMVARBLOCK("var")