; CHECK
;
; Program for Proteus
;
; (C) 2003-2004 Simone Zanella Productions
;
; Verify that the specified file does not contain characters outside of the ASCII range 32-126, 13, 10.
#!proteus -z
IF STREQ(ARGV(5), "")
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " source"
CONSOLELN ""
CONSOLELN "Purpose: verify that the specified file does not contain characters outside the range"
CONSOLELN "32-126 + CR/LF"
ABORT 0
FI
Admitted = CHR(13) CHR(10)
FOR X = 32 TO 126
Admitted = Admitted CHR(X)
NEXT
H = FOPEN(ARGV(5), 1)
IF EQ(H, -1)
CONSOLELN "File not found: " ARGV(5)
FI
N = 0
Primo = 0
WHILE NOT(FEOF(H))
L = FREAD(H, 512)
P = STRCPBRK(L, Admitted)
N2 = N
Rest = L
WHILE NEQ(P, 0)
IF NOT(Primo)
CONSOLELN "Disallowed character offset:"
Primo = 1
FI
CONSOLELN PFORMAT("06X", ADD(@N2, DEC(P))) " chr(" ASC(SUBSTR(Rest, P, 1)) ")"
Rest = RESTFROM(Rest, INC(P))
P = STRCPBRK(Rest, Admitted)
LOOP
ADD(@N, STRLEN(L))
LOOP
FCLOSE(H)
IF NOT(Primo)
CONSOLELN "File is ok."
FI
ABORT 0