space
Previous Page | Next Page

Adding SAS Component Language Programs to Frames

Controlling the Execution of SCL Programs

There are several ways to control application execution in an SCL program for a frame. You can

You can use conditional SCL statements to alter the flow of a program. For example, to conditionally return control to the window:
object1:
   /* ...SCL statements... */
   if condition
      then return;
   /* ...SCL statements... */
return;

You can use the LINK statement to branch to a common labeled section in the same SCL program. For example:

object1:
   /* ...SCL statements... */
   link computeValue;
   /* ...SCL statements... */
return;

object2:
   /* ...SCL statements... */
   link computeValue;
return;

computeValue:
   /* ...SCL statements... */
return;

The labeled section computeValue may or may not correspond to an object of the same name. Labeled sections are not required for all objects on a frame; likewise, a labeled section can exist with or without an associated frame object. The computeValue section executes each time

For additional information on controlling application flow with SCL, refer to the topics on submitting SAS statements and using macro variables in SAS Component Language: Reference.


Processing Custom Commands in SCL Programs

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

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.

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;

space
Previous Page | Next Page | Top of Page