Chapter Contents |
Previous |
Next |
CONTROL |
Category: | Control Flow |
Comparisons: | SAS Statement with limitations in SCL |
Syntax | |
Details | |
Examples | |
Example 1: Using the ASIS Option | |
Example 2: Controlling a Program Interrupt | |
See Also |
Syntax |
CONTROL options; |
Type: Character
ALLCMDS provides the same functionality as the ALWAYS option and enables a program to intercept custom commands. In addition, ALLCMDS allows an SCL program to intercept procedure-specific commands. In FRAME entries only, ALLCMDS allows an SCL program to intercept full-screen global commands. For a listing of full-screen global commands, see EXECCMDI .
In PROGRAM entries, ALLCMDS combines the effects of ENTER and ERROR and forces statements in the MAIN section to execute even if a user issues commands that are not recognized by the procedure.
In FSEDIT applications, ALLCMDS and ALWAYS have the same functionality, and both enable an SCL program to intercept any procedure-specific or custom commands.
When ALLCMDS is specified, statements execute in the MAIN section before a command that is issued with the EXECCMD routine. This behavior could introduce an infinite loop. Either execute the EXECCMD routine conditionally or specify the command using EXECCMDI with the NOEXEC parameter.
FSVIEW applications ignore these options.
ALWAYS can be used if your application supports custom commands. When ALWAYS is specified, FSEDIT applications execute statements in the MAIN section before handling a command that is issued with the EXECCMD routine. This behavior could introduce an infinite loop. Either execute the EXECCMD routine conditionally or specify the command using EXECCMDI with the NOEXEC parameter.
FSVIEW applications ignore this option.
H
to halt and R
to resume.
A program can contain any number of CONTROL BREAK statements. For example, there can be one in each of the INIT, MAIN, and TERM sections or in any other labeled section. When a CONTROL BREAK statement executes, any previous CONTROL BREAK statement is overwritten so that only one is in effect at a time.
Use NOBREAK to restore the default behavior. NOBREAK clears the current CONTROL BREAK specification.
FSVIEW applications ignore this option.
In FSVIEW applications, this option has an effect only if the cursor is on a valid row when ENTER or a function key is pressed.
If you use ERROROFF to remove the error status from a continued portion of a field in an FSEDIT application, then you must also use a CONTROL ERROR statement in the program. If a user does not type in the continued portion of the field and the program does not have a CONTROL ERROR statement, the error flag is not removed from the continued portion of the field. As a result, the default error message may be displayed, saying that a data value is not valid.
Statements in a window variable block execute after the associated window variable is modified, but only if the value does not introduce an error. That is, the value must satisfy any attributes that have been defined for the window variable.
Statements in MAIN do not execute until statements in all the window variable sections for modified fields execute successfully. The sequence for executing window variable sections is determined by the physical position of the field in the window from left to right and from top to bottom.
If a field modification introduces an attribute error, the associated window variable section does not execute. However, other window variable sections for modified window variables do execute. To correct an attribute error, you can allow users to correct the error in the window, or you can include SCL statements that make a correction in the labeled section for other fields.
If ERROR, ALWAYS, or ALLCMDS is also specified, then MAIN executes after the window variable sections even if an error was introduced.
If the window contains an extended table, the window variable section for each modified window variable executes for a row before the putrow section executes. MAIN executes after the putrow section executes.
Note: If CONTROL LABEL is specified, a window variable section
must not contain a SUBMIT IMMEDIATE block.
Details |
The CONTROL statement controls the execution of labeled program sections and also controls the formatting of code in a submit block. A CONTROL statement option remains in effect until another CONTROL statement option overrides it. Multiple CONTROL statement options can be in effect at the same time.
Examples |
Use the ASIS option:
control asis; submit; data a; input x y z; datalines; 10 20 30 40 50 60 run; endsubmit; rc=preview('display');With the CONTROL ASIS statement in effect, the submit block executes without errors. If you remove the CONTROL ASIS statement, SCL formats the code within the block as follows when the code is submitted for processing:
data a; input x y z; datalines; 0 20 30 40 50 60 run;When formatted in this manner, the final statement contains a syntax error and the code cannot execute properly.
Define a break handler section labeled STOPINIT. When a user interrupts processing while SCL statements in INIT are executing, the STOPINIT label executes. If the loop index I is less than 350, execution of the program halts and control returns to the calling program. Otherwise, execution resumes. After the first loop is finished, execute CONTROL NOBREAK so that there is no break handler. If a user interrupts processing during the second loop, the SCL Break requestor window is displayed, and the statements in STOPINIT do not execute. The user can either abort or resume processing. Follow the same steps to define a new break handler section labeled STOPTERM in the TERM section.
INIT: /* define break label STOPINIT */ control break stopinit; /* loop 500 times to allow interrupt */ /* checking with control break */ /* if user interrupts, statements in */ /* label STOPINIT execute */ do i=1 to 500; put i=; end; /* reset so there is no break handler */ control nobreak; /* loop 500 times to allow interrupt */ /* checking without control break */ do i = 1 to 500; if (int(i/25) eq (i/25)) then put i=; end; return; MAIN: return; TERM: /* Define the new break label STOPTERM. */ control break stopterm; /* Loop 500 times to allow */ /* interrupt checking with control */ /* break. If user interrupts, */ /* statements in label STOPTERM */ /* execute. */ do j=1 to 500; put j=; end; /* Reset so there is no break handler. */ control nobreak; /* Loop 500 times to allow */ /* interrupt checking without control */ /* break. */ do j = 1 to 500; if (int(j/25) eq (j/25)) then put j=; end; return; STOPINIT: /* HALT if loop counter is less than 350, */ /* otherwise RESUME. */ /* Report the current status. */ put i=; if (i < 350) then _status_ = 'H'; else _status_ = 'R'; return; STOPTERM: /* HALT if loop counter is less than 350, */ /* otherwise RESUME. */ /* Report the current status. */ put j=; if (j < 350) then _status_ = 'H'; else _status_ = 'R'; return;
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.