space
Previous Page | Next Page

Adding SAS Component Language Programs to Frames

Constructing a Frame SCL Program

A typical SCL program for a frame consists of

This section describes how you can combine these elements to create the programs that control SAS/AF frames.

SCL Labeled Sections

A section in SCL begins with a label and ends with a RETURN statement. SCL programs for FRAME entries use reserved sections to process program initialization, main processing, and termination.

INIT:
  /* ...statements to initialize the application... */
return;

MAIN:
  /* ...statements to process user input... */
return;

TERM:
  /* ...statements to terminate the application... */
return;

In addition, you can add sections labeled with object names for each component that you add to the frame. The labeled section for a component executes when an action is performed on the component, such as selecting the component or changing its value. For example, if you have a push button named okButton on your frame, you could have the following labeled section in your SCL:

   okButton:
      dcl list message={'Are you sure you want to exit?'};
      response=messagebox(message, '!', 'YN', 'Confirm Exit','N',");
      rc=dellist(message);
   return;

The code in the okButton section automatically executes when the push button is selected.

In general,

For a detailed explanation of how labeled sections are processed, see How SCL Programs Execute for FRAME Entries.

SCL Statements

The labeled sections in frame SCL programs consist of one or more executable statements that control program flow. (Declarative statements, such as DECLARE or ARRAY, can occur anywhere in the program and do not have to exist in labeled sections.)

You can also use the following SAS language statements in SCL programs:

For details on SCL statements, refer to SAS Component Language: Reference.

SCL Routines and Functions

SCL provides a rich set of routines and functions that perform some action, such as the DISPLAY routine or the OPENSASFILEDIALOG function. For detailed information about these functions, refer to SAS Component Language: Reference.

In addition, SCL supports nearly all of the functions of the Base SAS language. For details on the Base SAS functions, see SAS Language Reference: Dictionary.


SCL Variables

Each variable used in an SCL entry represents a specific data type. SCL supports the following data types:

Character

declared with the keyword CHAR

Numeric

declared with the keyword NUM

SCL List

declared with the keyword LIST

Object

declared with the keyword OBJECT or with a specific four-level class name

SCL provides several automatically defined system variables, such as

See SAS Component Language: Reference for a complete list of system variables and their data types.

Automatic system variables like _FRAME_ and _STATUS_ are declared internally, so you can use them without having to declare them in your SCL. Objects created on a frame are also declared automatically, and as long as you compile the frame's SCL entry from the frame, the SCL compiler recognizes them.

All other variables must be defined using the DECLARE statement. Consider the following code:

DECLARE  NUM         n1 n2,
         NUM         n3[15],
         CHAR        c1,
         CHAR(10)    c2,
         LIST        myList = {};
         OBJECT      obj1 objs[5],
         classname   obj2;


Dot Notation and SCL

SCL provides dot notation for direct access to component properties. Dot notation is intended to save time, improve code readability, and reduce the amount of coding necessary. It also improves the performance of your applications by providing additional compile-time validation. For example, you can use it to check the method's argument type. You can also use it to execute methods and to access component attributes without having to use SEND or NOTIFY routines.

You can use dot notation in any of the following forms:

object.method(<arguments>);
return-value=object.method(<arguments>);
object.attribute=value;
value=object.attribute;
if (object.method(<arguments>)) then ...
if (object.attribute) then ...

where

object

specifies an object or an automatic system variable (such as _CFRAME_, _FRAME_, or _SELF_) whose type is object.

method

specifies the name of the method to execute.

arguments

specifies one or more arguments based on the appropriate method signature.

return value

specifies the value returned by a method (if any).

attribute

specifies an attribute that exists on object.

value

specifies a value assigned to or queried from the attribute.

Dot notation can be used to set or query attributes. For example, suppose object1 is a text entry control:

/* Setting the text color */
   object1.textColor='yellow';

/* Querying the text color.                  */
/* object1's textColor attribute is returned */
/* to the local SCL variable 'color'         */
   color = object1.textColor;

Dot notation also is used to call methods. For example,

object._cursor();

is equivalent to

call send(object, '_cursor');

For compatibility with legacy programs, you can continue to use CALL SEND and CALL NOTIFY to invoke methods.

You can use dot notation to call methods on objects in several ways, provided the method contains the appropriate signature information. For example,

/* With a return variable */
   cost=object1.getPrice(itemnum);

/* Without a return variable */
   object1.getPrice(itemnum, cost);

/* In an IF statement */
   if object1.getPrice(itemnum) > 100 then do...

Note:   Objects that are created on a frame and automatic system variables (such as _FRAME_ ) are automatically declared as objects. You can refer to these objects in dot notation without having to declare them in your SCL programs. To use dot notation with legacy objects that you add to a frame, you must first select "Use object name as ID in SCL" for those objects in the Properties window.  [cautionend]

For more information about dot notation, refer to SAS Component Language: Reference and the SAS/AF online Help.

space
Previous Page | Next Page | Top of Page