; LINER
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Copy each line, adding to the left its number
FUNCTION ONSTART()
IF STREQ(ARGV(3), "..")
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " source destination"
CONSOLELN ""
CONSOLELN "Purpose: write to destination each line in source, prefixed by its number"
ABORT 0
FI
RETURN
FUNCTION ONEND()
; First, determine the number of lines in the file; at the end,
; open the file again and read each number, writing it after prefixed
; by each number. Every line starts at the same column, because
; the prefix has fixed length.
h = FOPEN(ARGV(3), 1)
m = STRLEN(PUB(N))
nn = 1
IF NEQ(h, -1)
WHILE NOT(FEOF(h))
PRINTLN PADL(nn, m, "0") ": " FREADLN(h)
INC(@nn)
LOOP
FCLOSE(h)
FI
RETURN