home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Icon 8.1 / mep1 / Samples / Programs / head.icn < prev    next >
Encoding:
Text File  |  1989-05-09  |  721 b   |  30 lines  |  [TEXT/PICN]

  1. ############################################################################
  2. #
  3. #  head.icn
  4. #  
  5. #     This program prints the first lines of a file.  The user
  6. #  is prompted with a Get File dialog and the program continues to
  7. #  process files until the user selects Cancel in a Get File dialog.
  8. #  
  9. #  Option:
  10. #  
  11. #       n    Number of lines to print.  The default is 10.
  12. #
  13. #############################################################################
  14.  
  15. procedure main(args)
  16.     local i, name, infile
  17.     
  18.     i := integer(args[1]) | 10
  19.  
  20.     while name := getfile("File?") do {
  21.         close(\infile)
  22.         infile := open(name) | {
  23.             write(&errout,"*** cannot open ",name)
  24.             next
  25.             }
  26.         every 1 to i do
  27.             write(read(infile)) | break
  28.         }
  29. end
  30.