C/SIDE automatically declares and initializes a number of variables that you can use when you develop applications. The following table describes the system-defined variables.

System-defined variable Comments

Rec

When a record is modified, this variable specifies the current record, including the changes that are made.

xRec

When a record is modified, this variable specifies the original values of the record, before the changes.

CurrForm

This variable specifies the current form. You can access the controls of the form through this variable and set the dynamic properties of the form and its controls.

CurrReport

This variable specifies the current report.

RequestOptionsForm

This variable specifies the request options form for the current report.

CurrFieldNo

This variable specifies the field number of the current field in the current form. Retained for compatibility reasons.

In addition, some triggers, such as the OnFormat trigger of a control, have a parameter that is defined as a local variable.

Example

The following example shows how to use the Rec and xRec pair of records.

In an application, data is stored in two tables, a header table and a line table. The header table contains general information about, for example, sales orders, while the line table contains the specific order lines. The form that you use to enter information into the header table has fields that contain the customer’s address. These fields are related to the Customer table, and can be filled by using a lookup function in the field that establishes the relationship. In the header table, only the customer number is stored, and the other fields with customer information, such as name and address, are retrieved from the Customer table when the Customer No. field is validated.

In some situations, the user should be able to change the customer number, and in other situations the user should not be able to change it. If the order has already been shipped, for example, the user should not be able to change the customer number. If there is an incorrect number on an order that has not been processed completely, the user should be able to correct the error.

You could use the Rec and xRec variables to design your application in the following way:

  • When validating the customer number field, check whether the order has shipped.

  • If the order has shipped, compare the customer number fields in the xRec and Rec records. If they differ, reject the change.