!USR0:TAIL.PCL.2 18-Nov-84 LQ+3D.7H.34M.28S., by BUDD ! USR1:TYPE.PCL.2 18-Nov-84 LQ+3D.7H.26M.36S., by BUDD; ! TURN INTO "TAIL" ! Enhansment to the TOPS20 command TYPE. John Purretta Sept 81 String TAIL_FILE_NAME ! Global holding last filespec typed Command TAIL; Begin Integer CHANNEL_1, B_LINE, E_LINE, LINE, FLAG_1, EOFNUM; String TEXT, STRING_1; External String TAIL_FILE_NAME; Guide "of file"; Parse( File (Input, Wild, Default TAIL_FILE_NAME, Default_gen 0, Help "file name"):TAIL_FILE_NAME = $filel; ); Guide "from"; Parse( Number (Help "# of lines from End Of File", Default "20"): EOFNUM = $value; ); Parse Eol; ! This reads the file, and counts the lines CHANNEL_1 = $Open(TAIL_FILE_NAME,$Input); ! Open the file if CHANNEL_1 = 0 then Abort $Lasterror; ! Shouldn't fail Until $Eof(CHANNEL_1) neq 0 do begin ! Loop until EOF TEXT = $Read(CHANNEL_1); ! read a line LINE = LINE + 1; ! Increment counter end; Call $Close(CHANNEL_1); ! Close the file B_LINE = LINE - EOFNUM; ! Determine starting line E_LINE = LINE; ! and ending line if B_LINE < 1 then B_LINE = 1; ! No negatives display "[.....line " + $string(B_LINE) + ".....]"; ! (might be useful) ! Counts lines as steps thru file. If in range specified ! by the user the line is typed. CHANNEL_1 = $Open(TAIL_FILE_NAME,$Input); ! Open the file if CHANNEL_1 = 0 then Abort $Lasterror; ! Shouldn't fail LINE = 1; ! Set line counter Until $Eof(CHANNEL_1) neq 0 do begin ! Until EOF TEXT = $Read(CHANNEL_1); ! read a LINE if LINE geq B_LINE then display TEXT; ! In if LINE geq E_LINE then Goto Close; ! Range?? LINE = LINE + 1; ! Increment counter end; ! End loop Close: Call $Close(CHANNEL_1); ! Close the file Fin: end; ! End TYPE.PCL ***