Adding SAS Component Language Programs to Frames |
You can use SCL to access other entries that you may need for your application, such as frames and other SCL programs. You can use the DISPLAY routine to invoke another SAS catalog entry, including FRAME, SCL, CBT, and PROGRAM entries. For example,
call display('sasuser.mycat.myApp.scl');
invokes the SCL entry named myApp. The calling program transfers control to myApp and waits for it to finish processing.
SCL also enables you to pass parameters between different entry types. In general, any argument to an SCL function, routine, or method can be
call display('myFrame.frame', 2);
call display('myApp.scl', myTable);
call display('dlg.frame', listBox1.selectedItem);
Character constants, numeric constants, and expressions are passed by value. You can use any SCL variable to pass parameters by reference to another entry. To use the DISPLAY function with a return value, you must include an ENTRY statement in the frame SCL of the called FRAME entry. For example, consider the following SCL code:
validUser=DISPLAY('password.frame', userid);
If PASSWORD.FRAME contained a text entry control named userPassword in which a user could provide a valid password, the frame's SCL could contain
/* FRAME SCL for mylib.mycat.password.frame */ entry userid:input:num return=num; term: dcl char pwd; dcl num isValid; /* Assume that the user ID is validated in some */ /* way to establish a value for the password. */ if userPassword.text = pwd then isValid=1; else isValid=2; return(isValid);
For details on passing parameters to other SAS catalog entries, see the ENTRY statement in SAS Component Language: Reference.
Opening Other Windows |
Your applications can consist of any number of windows and dialog boxes. Using the DISPLAY routine, you can open other windows in your application as needed.
For example, assume that a frame contains three push button controls named Rates, Lenders, and Recalculate. The SCL entry for that frame can call a FRAME entry named LOANRATES.FRAME when a user clicks the Rates button, and it can call a FRAME entry named LENDERINFO.FRAME when a user clicks Lenders. The frame SCL also runs another SCL entry when a user clicks Recalculate.
RATES: call display('loanRates.frame'); return; LENDERS: call display('lenderInfo.frame', 2, 'North', listBox1.selectedItem); return; RECALCULATE: call display('sasuser.myapp.calculate.scl'); return;
You can also invoke full-screen applications from a SAS/AF frame application. For example, the following SCL code enables a user to access the FSEDIT window and to browse the RECORDS.CLIENTS table after clicking on the active frame:
CLIENTS: call fsedit('records.clients',",'browse'); return;
Calling Dialog Boxes from an Application |
You can present information in SAS/AF applications through dialog boxes as well as through standard frames. Your SCL code can call dialog boxes using any of the following:
the DIALOG routine or function
Much like CALL DISPLAY, the DIALOG function enables you to display a FRAME entry. DIALOG differs from CALL DISPLAY in that it displays the frame as a modal window, which disables all other SAS windows until the dialog frame is closed. For example:
CALL DIALOG('verify.frame');or
validInput=DIALOG('validate.frame', some-variable);To use the DIALOG function with a return value, you must include an ENTRY statement in the frame SCL of the called FRAME entry.
You can use the MESSAGEBOX function to display a host message window for informational, warning, or error messages. For example:
VALIDATE: dcl list msgList={'SAS table not specified.'}; dcl num rc; choice=MessageBox(msgList, '!', 'OC', 'Validation'); if choice='CANCEL' then call execcmd('end'); rc=dellist(msgList); return;You can use the MESSAGEBOX function instead of the _MSG_ automatic variable to display warnings.
the SCL File or Entry Dialog functions
You can use the OPENSASFILEDIALOG and SAVESASFILEDIALOG functions to manipulate two-level SAS filenames just as you would use DIRLIST. Likewise, you can use the OPENENTRYDIALOG and SAVEENTRYDIALOG functions to manipulate SAS catalog entry names just as you would use CATLIST. For example,
selected=OpenEntryDialog('RANGE');opens a catalog entry selector, displays available RANGE entries, and returns the user's selections.
For complete information on these functions, see SAS Component Language: Reference.
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.