home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / BBEdit / MacBob 1.0ß2 / Examples / ListFile.bob < prev    next >
Encoding:
Text File  |  1995-12-07  |  411 b   |  33 lines  |  [TEXT/R*ch]

  1. /***
  2.  *
  3.  *    ListFile.bob - List a text file with line numbers.
  4.  *
  5.  ***/
  6.  
  7. main ()
  8. {
  9.     if (getfile("TEXT"))
  10.         ProcessFile();
  11.     else
  12.         print("ERROR: Couldn't get file\n");
  13. }
  14.  
  15.  
  16. ProcessFile ( ; c, i, line)
  17. {
  18.     line = "";
  19.     i = 1;
  20.  
  21.     while ((c = getc(stdin)) != -1) {
  22.         line += c;
  23.         if (c == 13) {
  24.             print(i++, ":\t", line);
  25.             line = "";
  26.         }
  27.     }
  28.     if (sizeof(line) != 0)
  29.         print(i, ":    ", line, "\n");
  30.     print("<END>\n");
  31. }
  32.  
  33.