QGrid

Using the plug-in


Using expressions as QGrid parameters

Starting with v1.1, some QGrid commands accept expressions as parameters.

These expressions can be entire 4D functions (methods or fragments) that return the right data type. QGrid executes these expressions and feeds their result into the plug-in command. Expressions should be put between quotes, in the same way strings 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.
"My_Get_Picture (param)" This is a method that accepts a parameter. Internally, this method should be constructed as a function returning a picture in $0.
"Substring([Table]Field;1;15)" This is another valid expression that returns textual data.
"150" A simple numeric constant in quotes. It's also a valid expression.

 

What kinds of expressions you will need

QGrid expects expressions in 3 cases:

  1. to denote the number of cells in the grid (result is number)
  2. to denote the source of the picture object (result is picture)
  3. to denote the source of the caption object (result is textual)

Iterative expressions: In cases 2 and 3 the expression has to be executed once for each cell that will be displayed, so there's a need for iteration. In order to correctly instruct QGrid to iterate, you should use in your expression QGrid's own iteration counter that is in process variable gQGCurrentCell.

For example, a valid expression that traverses a picture array should be "My_Pict_Array{gQGCurrentCell}"

gQGCurrentCell is 1 for the first cell and its max 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.