home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug017.arc / SCR_PRIN.INC < prev    next >
Text File  |  1979-12-31  |  1KB  |  45 lines

  1.  
  2. Program Screen or Printer;
  3.  
  4. {To use this procedure in a program you need to do several things. }
  5.  
  6. {1.  In the main VAR list you must add the statement               }
  7.         Q:TEXT;
  8.  
  9. {2.  In the program all WRITE or WRITELN statements must start     }
  10. {    like the following ....                                       }
  11. {       Writeln(Q, .....                                           }
  12. {    If you omit the Q, then the computer will automatically       }
  13. {    send the output to the screen. Only the statements which      }
  14. {    include the Q, will give you the choice of screen or printer. }
  15.  
  16. {3.  The procedure must come before the main program BEGIN ..      }
  17. {       ..... END. block.                                          }
  18.  
  19. {4.  The procedure is called by simply writing its name in the     }
  20. {    main program.                                                 }
  21.  
  22. Procedure Device;
  23. Var Dev:char;
  24.  
  25. Begin
  26.   writeln('Which output device ? .. S<creen> or P<rinter> ? ');
  27.   repeat
  28.     read(dev);
  29.     writeln;
  30.   if not (dev in ['s','p','S','P']) then
  31.     begin
  32.       writeln(upcase(dev));
  33.       writeln('An "S" or a "P" expected. Try again.');
  34.     end;
  35.     until dev in ['S','s','p','P'];
  36.  
  37.     case dev of
  38.       's','S' : assign(Q,'CON:');
  39.       'p','P' : assign(Q,'LST:')
  40.     END; {CASE OF}
  41.  
  42. rewrite(Q);
  43.  
  44. end;{Procedure device}
  45.