Using SCL to Locate and Store Sample Script Files

The system option SASSCRIPT= defines the location of the SAS/CONNECT script files. The value of the SASSCRIPT= system option is a logical name or one or more aggregate storage locations (such as directories or partitioned data sets). Setting the SASSCRIPT= system option automatically generates the SAS system option, SASFRSCR. SASFRSCR is set to the value of a fileref that is used to build a list of scripts for SCL applications. When you establish a link while using SAS/ASSIST, this product uses the information provided by the SASFRSCR option to provide a list of available scripts. You can also build a similar menu of script files for user-written applications by accessing the SASFRSCR system option from an SCL program.
The following SCL program obtains the value of the SASFRSCR system option and uses it to create a list of scripts. For information about the SCL functions that are used in this example, see SAS Component Language: Reference .
INIT;
return;

MAIN:
      /* Get internally-assigned fileref.      */
   fileref=optgetc('sasfrscr');

      /* Open the directory (aggregate storage */
      /* location).                            */
   dirid=dopen(fileref);

      /* Get the number of files.              */
   numfiles=dnum(dirid);

      /* Define a custom selection list the    */
      /* length of the number of files and     */
      /* allowing users to make one choice.    */
   call setrow(numfiles,1);
return;

TERM:
      /* Close the directory.                  */
   rc=dclose(dirid);
return;

GETROW:
      /* Display the list of filenames.        */
   filename=dread(dirid,_currow_);
return;

PUTROW:
      /* Get directory pathname.               */
   fullname=pathname(fileref);

      /* Concatenate filename that user selects*/
      /* with directory pathname.              */
   name=fullname ||'/'|| filename;
      /* Other SCL statements to use complete  */
      /* filename stored in name.              */
return;