Difference between skip and advance
Difference between skip and advance
I have read the CSPro help about advance and skip but I am still not clear about it. Can you explain what the difference is between the advance and skip statements?
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Difference between skip and advance
In the CSPro helps, this is what is said about each:
What events are triggered for each field
The killfocus event of a field will be executed after a skip but the postproc will not be executed (unless, of course, the skip was placed in the postproc). So as soon as a skip is encountered, the killfocus is executed and then the focus is sent directly to the target of the skip field. That means that any events (preprocs/postprocs) located between the two fields won't be executed. For example:
In operator-controlled mode, you'll note that fields that are skipped turn yellow. This means that, although you've skipped past the fields, they'll still be saved to the data file.
In system-controlled mode, the fields turn a dark gray. This color indicates that the fields are disabled. They are not applicable because you've skipped past them, and the data will not be saved to the file.
The advance command works the same in both operator- and system- controlled modes.
Basically the way to think about these two commands is that a skip is used to move past a section that is not applicable to the person or household. An advance is used when moving past data that already has been entered and that is applicable to the person or household. Skip statements are much more common than advance statements.
The critical difference between the two comes down to two things:The skip statement skips to the specified field. If the field has multiple occurrences, either record or item, the occurrence number must be specified to skip to the correct occurrence.
The advance statement moves forward field-by-field to the specified field, executing preprocs and postprocs as it goes. 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.
What events are triggered for each field
The killfocus event of a field will be executed after a skip but the postproc will not be executed (unless, of course, the skip was placed in the postproc). So as soon as a skip is encountered, the killfocus is executed and then the focus is sent directly to the target of the skip field. That means that any events (preprocs/postprocs) located between the two fields won't be executed. For example:
PROC VAL1
preproc errmsg("VAL1: preproc"); skip to VAL3;
onfocus errmsg("VAL1: onfocus");
killfocus errmsg("VAL1: killfocus");
postproc errmsg("VAL1: postproc");
PROC VAL2
preproc errmsg("VAL2: preproc");
onfocus errmsg("VAL2: onfocus");
killfocus errmsg("VAL2: killfocus");
postproc errmsg("VAL2: postproc");
PROC VAL3
preproc errmsg("VAL3: preproc");
onfocus errmsg("VAL3: onfocus");
The output of this will be:preproc errmsg("VAL1: preproc"); skip to VAL3;
onfocus errmsg("VAL1: onfocus");
killfocus errmsg("VAL1: killfocus");
postproc errmsg("VAL1: postproc");
PROC VAL2
preproc errmsg("VAL2: preproc");
onfocus errmsg("VAL2: onfocus");
killfocus errmsg("VAL2: killfocus");
postproc errmsg("VAL2: postproc");
PROC VAL3
preproc errmsg("VAL3: preproc");
onfocus errmsg("VAL3: onfocus");
On the other hand, with an advance, all of the events that occur between the fields are executed. This means that there must be data already located in the fields that you're advancing past (or notappl has to be accepted for the field). As the help document says, the advance command is equivalent to continually pressing Enter to advance to the next field, until the target is reached. In the above example, if the skip was changed to an advance, and assuming that there was valid data located in VAL1 and VAL2, the output would be:VAL1: preproc
VAL1: killfocus
VAL3: preproc
VAL3: onfocus
How the data will appear in the data fileVAL1: preproc
VAL1: onfocus
VAL1: killfocus
VAL1: postproc
VAL2: preproc
VAL2: onfocus
VAL2: killfocus
VAL2: postproc
VAL3: preproc
VAL3: onfocus
In operator-controlled mode, you'll note that fields that are skipped turn yellow. This means that, although you've skipped past the fields, they'll still be saved to the data file.
In system-controlled mode, the fields turn a dark gray. This color indicates that the fields are disabled. They are not applicable because you've skipped past them, and the data will not be saved to the file.
The advance command works the same in both operator- and system- controlled modes.
Basically the way to think about these two commands is that a skip is used to move past a section that is not applicable to the person or household. An advance is used when moving past data that already has been entered and that is applicable to the person or household. Skip statements are much more common than advance statements.