Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the External File Viewer

This example creates a simple external file viewer that allows you to select the file to display and to change the font. In this application commands are issued from a pull-down menu.

  1. Create a frame containing an external file viewer object. Assign these object attributes:
    Name FILEVIEW
    Font SAS Font
    Scrollbars Vertical is turned on. Horizontal is turned on

    Do not specify a file or fileref.

  2. Create the PMENU entry to accompany the viewer. In the Program Editor, enter the following code:
    proc pmenu c=sasuser.menucat;
       menu fileview;
          item 'File' menu=file;
          item 'View' menu=view;
          item 'Help';
       menu file;
          item 'Open' selection=o;
          item 'End';
          selection o 'open';
       menu view;
          item 'Font' selection=f;
          selection f 'font';
    run;
    quit;

  3. Assign the PMENU Entry to FILEVIEW:

  4. Create the SCL program that determines what happens when the user makes a selection from the pull-down menu. Open the SOURCE entry for the frame and enter the following code:

 Note about code
length filename $ 200 fontlist 8 rc 8;

INIT:
   filename = '';
   fontlist = makelist(0, 'L') ;
   control allcmds ;
return;
 Note about code
MAIN:
   if ( _status_ = 'E' or _status_ = 'C') then
      return;
 Note about code
   select(word(1, 'u'));
 Note about code
   when ('OPEN');
      rc = filedialog('OPEN',filename);
      call notify('fileview','_set_file_',
                   filename, 'n');
 Note about code
   when ('FONT');
      fontlist = fontsel(fontlist,' ' );
      call notify('fileview', '_set_font_',
                   fontlist);
   otherwise;
end;
 Note about code
call nextcmd();
return;
 Note about code
TERM:
   rc = dellist(fontlist);
return;
  1. Compile and save the program. Test the viewer with the TESTAF command:


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.