You can add custom command processing to your frame
SCL programs to control program flow. A custom command can be any
name that does not correspond to an AF window command or SAS global
command and that you implement in the MAIN section of your frame SCL
program. A user issues commands by typing on a command line, by pressing
a function key with a defined command, or by selecting items on the
frame, including menu selections or commands that are associated with
visual controls.
To implement a custom
command, you must
-
select a unique command name (that
is, one that differs from all AF window commands and SAS global commands).
-
add a CONTROL statement to change
the default behavior for command processing during SCL program execution.
Alternatively, you can set the frame's
commandProcessing
attribute to
Run main
.
-
add code to the MAIN section of
the frame's SCL program to read the custom command from the command
line, process the custom command, and prevent the SAS command processor
from evaluating the custom command.
The CONTROL statement
controls the execution of labeled sections in an SCL program. Typically,
you add this statement to the INIT section of your program.
-
Use CONTROL ALLCMDS to execute
the MAIN section when a procedure-specific or custom command is issued,
or when a user presses the ENTER key, even if an error flag is in
effect for an object on the frame.
-
Use CONTROL ALWAYS to execute the
MAIN section when a custom command is issued or when a user presses
the ENTER key, even if an error flag is in effect for an object on
the frame.
-
Use CONTROL ENTER to execute the
MAIN section when a custom command is issued or when a user presses
the ENTER key, unless an error flag is in effect for an object on
the frame.
You can use the WORD
function to return the command for processing, using the syntax
command=word(n <,case>);
where
command is the word that is currently in the command buffer,
n is the position (either 1, 2, or 3) of the
word in the command, and
case is an optional parameter that converts the word to either uppercase
('U') or lowercase ('L').
You can use the NEXTCMD
routine to remove the current command from the command buffer, using
the syntax
call nextcmd();
If you do not
remove a custom command from the command buffer, SAS issues an error
message.
For example, consider
a frame that contains a toolbar object on which each button is set
to issue a different command. These commands can be a mixture of valid
SAS commands or custom commands that you implement in the MAIN section
of the frame's SCL program:
dcl char(8) command;
INIT:
control always;
return;
MAIN:
command=word(1, 'u');
select command;
when ('CUSTOM1')
/* ...code to process the CUSTOM1 command... */
call nextcmd();
when ('CUSTOM2')
/* ...code to process the CUSTOM2 command... */
call nextcmd();
otherwise;
end;
return;