Data type Code block Foundation

The data type "code block" designates a value containing executable code. Using a code block, executable program code can be assigned to a variable. The program code is executed whenever the variable is passed to the function Eval().

Like an array, a literal code block is enclosed in curly braces {}. A code block is different from an array because the characters ||must be specified after the opening curly { brace for a code block. These two characters are followed by a one or more comma separated expressions. Between the characters ||, a parameter list can be specified to allow the code block to receive additional values from the function Eval(). The following lines show examples for simple literal code blocks:

{|| cString } 
{|n| n + 5 } 
{|value,min,max| value >= min .AND. max >= value } 
{|x,value| x+=value , QOut(x) } 

A code block is an extremely powerful tool that can be used to organize Xbase++ programs in a flexible manner. Code blocks, like arrays, cannot be stored in DBF files, but may be saved in XPF files using the command SAVE. An overview of code blocks is found in the chapter "Operations using Code Blocks".


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.