The
advance statement moves forward, field by field, to the specified field, executing logic in fields'
preproc and
postproc events as it proceeds. It acts as though the Enter key were pressed repeatedly until either the specified field appears or one of the procedures executed during the advance goes to a different field.
The optional field_name is either the name of a field or is a string variable specifying the name of the field. If the field_name is not specified, the program attempts to advance to the end of the level.
The target field can be located in any record at the same level as the current field, but it cannot be located at a different level. The field must be later on the path than the current field, meaning that it is a field that has not yet been entered. If the field has already been entered, an error message will be displayed during data entry. If you do not know whether the field is earlier in the data path, use the
move statement.
Note that the
advance statement behaves differently from the
skip statement, moving
over some number of fields, rather than skipping
past the fields.
If you want to conditionally execute logic based on whether or not the program is advancing, the
inadvance function indicates if an advance is in progress.
PROC CEB
preproc
// for girls aged less than 15, prefill in 0 for children ever born, but
// keep the information on path in case the keyer wants to change it
if AGE < 15 then
CEB = 0;
CEB_M = 0;
CEM_F = 0;
advance to MARITAL_AGE;
endif;