home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / print.seq < prev    next >
Text File  |  1991-03-06  |  2KB  |  46 lines

  1. \ PRINT.SEQ     A simple utility to allow printing to a disk file.
  2.  
  3. comment:
  4.  
  5.  This utility allow all printing to be sent to a disk file rather than the
  6. printer. Use it after loading as follows:
  7.  
  8.         PFILE MYPRNT.PRN <Enter>        \ select a file to print to
  9.         PRINT WORDS <Enter>             \ print a list of words
  10.         PCLOSE <Enter>                  \ close the print file
  11.  
  12.   Additional PRINT statments issued after a PFILE, and before a PCLOSE will
  13. be appended to the same print file.
  14.  
  15. comment;
  16.  
  17. : pclose        ( --- )         \ Restore printing to the printer.
  18.                 ['] 0= save!> pathset           \ disable path tool
  19.                 prnhndl hclose drop
  20.                 " PRN." prnhndl ">handle
  21.                 write-only prnhndl hopen drop
  22.                 restore> pathset                \ restore path tool
  23.                 ['] <?ptr.ready> is ?printer.ready ;
  24.  
  25. ' pclose alias toprinter
  26.  
  27.                                 \ a1 = addr of filename to make & print into
  28.                                 \       a1 is a counted string.
  29. : $pfile        ( a1 --- f1 )   \ f1 = true if failed to make file else false
  30.                 ['] 0= save!> pathset           \ disable path tool
  31.                 prnhndl hclose drop
  32.                 0 save!> defext                 \ no default extention
  33.                 ( a1 --- ) prnhndl $>handle
  34.                 restore> defext                 \ re-enable default ext.
  35.                 prnhndl hcreate
  36.                 restore> pathset                \ restore path tool
  37.                 if      pclose true
  38.                 else    ['] true is ?printer.ready false
  39.                 then    ;
  40.  
  41. : pfile         ( | name --- )  \ Print is to goto diskfile "name"
  42.                 bl word $pfile abort" Failed to CREATE file." ;
  43.  
  44. ' pfile alias fileprint
  45.  
  46.