home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / P_FOTRAN.LZH / DEMOS.FOR / PRINTF.FOR < prev    next >
Text File  |  1987-12-31  |  2KB  |  48 lines

  1.     program printf
  2. *
  3. *   Utility program to copy a variable-length formatted
  4. *   file from disc (where the first character of each line
  5. *   has not been interpreted as carriage-control)
  6. *   to the printer (with carriage-control interpretation)
  7. *
  8. *   To print a disc file, install the executable file PRINTF.PRG
  9. *   as a TOS-takes-parameters application (or alternatively rename
  10. *   the executable file as PRINTF.TTP), and, after executing the
  11. *   program by double-clicking, type the name of the disc file to
  12. *   be printed in the Parameters line of the OPEN APPLICATION box
  13. *
  14.     parameter (maxlen = 200)
  15.     character fname*65, pname*4, text1*12, text*78, line*(maxlen)
  16.     parameter (text1 = 'Cannot open ')
  17.     parameter (pname = 'PRN:')
  18.     integer funit, punit, ind
  19.     parameter (funit = 5, punit = 6)
  20. *   Get the filename from the command line
  21.     call getcom(fname)
  22. *   Open the disc file
  23.     open (funit, file = fname, status = 'old', err = 90)
  24. *   Open the printer
  25.     open (punit, file = pname, status = 'new', err = 91)
  26. *   Main loop to read each line from the disc file, and then
  27. *   send it to the printer, having removed trailing blanks
  28. 10    read (funit, 80, err = 92, end = 100) line
  29.     do 20 ind = maxlen, 1, -1
  30.     if (line(ind:ind) .ne. ' ') goto 30
  31. 20    continue
  32. 30    if (ind .lt. 1) ind = 1
  33.     write (punit, 80, err = 93) line(1:ind)
  34.     goto 10
  35. *   Format
  36. 80    format(A)
  37. *   Errors
  38. 90    text = text1//fname
  39.     goto 99
  40. 91    text = text1//pname
  41.     goto 99
  42. 92    text = 'Cannot read '//fname
  43.     goto 99
  44. 93    text = 'Cannot write '//pname
  45. 99    print *, text
  46. *   Terminate
  47. 100    end
  48.