; CHGDAT2
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Change in each line the first date found from the format 'dd/mm/yy[yy]'
; to the format 'dd mmm yyyy'; the date must use at least one of the
; separators in Seps (which must also include ' ').
; This program is similar to chgdate.prt, but uses the library functions
; for dates and the dynamic tokenizer to speed up operations.
; Initialize variables
FUNCTION ONSTART()
IF STREQ(ARGV(3), "..")
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " source destination"
CONSOLELN ""
CONSOLELN "Purpose: change dates from numeric to alphanumeric"
ABORT 0
FI
_Seps = " ,;:.()[]<>-{}"
_MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
RETURN
TKH = TOKNEW(L, Seps)
; Save token number in line
NTK = TOKNUM(TKH)
NewL = L
; For each token..
FOR CurTok = 1 TO NTK
PL = TOKGET(TKH, CurTok)
; The token is a date?
IF ISDATE(PL)
; Find where the date is in NewL
P = TOKPOS(TKH, CurTok)
; Replace date in NewL
NewL = INSERT(DELETE(NewL, P, STRLEN(PL)), P, \
; New date
PADL(DAY(PL), 2, " ") " " CMONTH(PL) " " YEAR(PL))
; Exit from FOR, because the position of the following tokens has changed
BREAK
FI
NEXT
TOKFREE(TKH)
PRINTLN NewL