Using expressions as parameters
You will notice that some QGrid commands accept expressions as parameters. These expressions are 4D code (methods or fragments) that return a data type suitable to the operation in question. QGrid executes the expression and feeds the result into the plug-in command.
Expressions should be put between quotes, in the same way texts are. The following are examples of valid expressions:
"Records in selection([Table])"
Returns a numeric value that can be used in any QGrid command that expects a numeric value.
This is a method that accepts a parameter. Internally, this method should be constructed as a function returning a picture in $0.
This is another valid expression that returns textual data.
A simple numeric constant in quotes. It's also a valid expression.
Kinds of expressions you will need
QGrid expects expressions in 3 cases:
- to denote the number of cells in the grid (result is number)
- to denote the source of picture data (result is picture)
- to denote the source of caption data (result is textual)
When the expression must be executed for each cell (as in the cases of the picture and data sources), there's a need for iteration.
In order to correctly instruct QGrid to iterate, use in your expression QGrid's own iteration counter, process variable gQGCurrentCell.
For example, this is an expression that traverses a picture array:
WARNING gQGCurrentCell is 1 for the first cell and its highest value is the declared number of cells. Before an iteration starts, as well as after it completes, gQGCurrentCell has no meaningful values and should not be used for any purpose.