Variables used in forms

You can use global variables (both those defined by users and those supplied by QMF™) and form variables in QMF forms. A variable can replace a string of text or a numeric value. You can assign different values to the variable to produce different reports without changing the form.

Global variables in forms make it possible for multiple queries to share the same form. For example, using the SET GLOBAL command, you can assign a string of text such as "Annual Report for 2005" to a variable such as &ann and use it in a form. You can use the SHOW GLOBALS command to display some or all of the available global variables. On the GLOBALS panel, you can set or change any variable that has an entry field in the Value column enclosed by brackets or parentheses. Otherwise, the variable is read-only. Change existing values by typing over the value shown.

By default, values for global variables persist for the duration of the QMF session or until you reset them. However, the DSQEC_USERGLV_SAV global variable can be set to save global variable values from one session to another.

Normally, QMF removes trailing blanks from character values for substitution variables. For numeric values, leading blanks are removed. To retain leading or trailing blanks in substitution variable values in the report, append _B to any variable on a form panel (for example: &3_B). This special syntax is meaningful only for substitution variables in the form panels. It does not apply to substitution variables used in queries or procedures, or to the variables &ROW, &DATE, &TIME, and &PAGE.

QMF supplies variables called form variables that return system information or information about your report. The form variables are the following:
  • &ROW
  • &COUNT
  • &DATE
  • &TIME
  • &PAGE
  • &CALCid
  • &n
  • &an

These variables are defined in the context of the form panel they are entered on and where they appear in the report. They are explained (if applicable) in the individual sections for each form panel.

The following table shows which variables are allowed on the various form panels.

Table 1. Variables allowed on form panels
  F.PAGE F.BREAK F.CALC F.COLUMNS (Column Definition) F.CONDITIONS F.DETAIL F.FINAL
Head Foot Head Foot       Head Block  
&ROW x x x x x x x x x x
&DATE x x x x x x x x x x
&TIME x x x x x x x x x x
&PAGE x x x x x     x x x
&COUNT       x x       x x
&CALCid       x         x x
&n x x x x x x x x x x
&an       x x       x x
Global variables x x x x x x x x x x

Single or double quotation marks do not affect variables used in the form.