Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
Labeled sections are program segments that are designed to be called only within the program in which they are defined. Labeled sections begin with a label and end with a RETURN statement. A label may be one of the reserved labels such as INIT or MAIN; it may correspond to a field name, window-variable name, or object name in your application; or it may simply identify a module that is called repetitively, such as a module that sorts data.
Labeled sections are a good solution when you are working within one SCL program because they can help divide the program into smaller, simpler pieces.
For example, the following SCL program contains an INIT section that is executed before the application window is displayed; two sections that correspond to window variables, NAME and ADDRESS; and a MAIN section that is executed each time the user updates a field in the window.
init: ...some SCL statements... return; name: ...some SCL statements... return; address: ...some SCL statements... return; main: ...some SCL statements... return;
Reserved Labels |
There are five reserved labels:
An SCL program for FSEDIT or FSBROWSE applications must contain at least one of the following reserved labels: INIT, MAIN, or TERM. If a program does not include at least one of these three reserved labels, the procedure never passes control to your SCL program. If a program does not contain all three of these reserved labels, you get one or more warning messages when you compile the program.
The FSEINIT and FSETERM labels are optional. The compiler does not issue any warnings if these labels are not present.
Neither SCL programs for FRAME entries nor programs in SCL entries that contain method block definitions require any reserved sections.
For more information about the FSVIEW, FSEDIT, and FSBROWSE procedures, see SAS/FSP Software: Usage and Reference and SAS/AF and SAS/FSP Software: Changes and Enhancements, Release 6.07. For more information about FRAME applications, see SAS Guide to Applications Development.
Window Variable Sections |
The sequence for executing window variable sections
is determined by the physical position of the window element. Window variable
sections execute sequentially for each window element, from left to right
and from top to bottom. A window variable section must be labeled with the
name of the associated window variable. For more information about window
variables, see
SAS Guide to Applications Development.
INIT: control error; return; Name: if error(Name) then do; erroroff Name; Name=default-value-assigned-elsewhere; _msg_= 'Value was invalid and has been reset.'; end; return;
Using a window variable section in this manner reduces overhead because the program's MAIN section executes only after the window variable sections for all modified window variables have executed correctly.
If a program also uses CONTROL ERROR, CONTROL ALWAYS, or CONTROL ALLCMDS, then the MAIN section executes after the window variable sections even if an error has been introduced. For more information about the CONTROL statement, see CONTROL.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.