; PALIND
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Print out all palindromes longer than two characters found in input.
FUNCTION ONSTART()
IF STREQ(ARGV(3), "..")
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " source destination"
CONSOLELN ""
CONSOLELN "Purpose: write to destination all palindromes found in source"
ABORT 0
FI
RETURN
FUNCTION IsPalind(s)
ts = REVERSE(s)
RETURN STREQ(ts, s)
; Count number of words in line
TKH = TOKNEW(L, " ")
NTK = TOKNUM(TKH)
; Print all palindromes found
FOR CurTok = 1 TO NTK
W = TOKGET(TKH, CurTok)
IF AND(GT(STRLEN(W), 2), IsPalind(W))
PRINTLN W ", line " N
FI
NEXT
TOKFREE(TKH)