Previous Page | Next Page

Window and Display Features

Example

This example illustrates the following features:

  • multiple windows

  • the repeat feature

  • command- and message-line usage

  • a large display surface needing scrolling

  • windows linked to data set transactions

This example uses two windows, FIND and ED. The FIND window instructs you to enter a name. Then a data set is searched for all the names starting with the entered value. If no observations are found, you receive the following message:

   Not found, enter request

If any observations are found, they are displayed in the ED window. You can then edit all the fields. If several observations are found, you need to use the scrolling commands to view the entire display surface. If you enter the SUBMIT command, the data are updated in place in the data set. Otherwise, you receive the following message:

   Not replaced, enter request

If you enter a blank field for the request, you are advised that EXIT is the keyword needed to exit the system. Here is the code:

   start findedit;
      window ed rows=10 columns=40 icolumn=40 cmndline=c;
      window find rows=5 columns=35 icolumn=1 msgline=msg;
      edit user.class;
      display ed ( "Enter a name in the FIND window, and this"
      / "window will display the observations "
      / "starting with that name. Then you can"
      / "edit them and enter the submit command"
      / "to replace them in the data set. Enter cancel"
      / "to not replace the values in the data set."
      /
      / "Enter exit as a name to exit the program." );
      do while(1);
         msg=' ';
         again:
         name=" ";
         display find ("Search for name: " name);
         if name=" " then
            do;
               msg='Enter exit to end';
               goto again;
            end;
         if name="exit" then goto x;
         if name="PAUSE" then
            do;
               pause;
               msg='Enter again';
               goto again;
            end;
         find all where(name=:name) into p;
         if nrow(p)=0 then
            do;
               msg='Not found, enter request';
               goto again;
            end;
         read point p;
         display ed (//" name: " name
            " sex: " sex
            " age: " age
            /" height: " height
            " weight: " weight ) repeat;
         if c='submit' then
            do;
               msg="replaced, enter request";
               replace point p;
            end;
         else
            do;
              msg='Not replaced, enter request';
           end;
      end;
      x:
      display find ("Closing Data Set and Exiting");
      close user.class;
      window close=ed;
      window close=find;
   finish findedit;
   run findedit;
Previous Page | Next Page | Top of Page