/* $VER: Diary.xdme 1.0 (01 Aug 1995) */
/* Copyright © 1995 Fergus Duniho */
/* An ARexx script for maintaining a diary with XDME */

IF ~Show("L","rexxreqtools.library") THEN
    IF ~addlib("rexxreqtools.library", 0, -30) THEN EXIT

/* Change these variables to suit your own needs */
path = GetEnv("Diary")
name = GetEnv("MyName")

today = date(s)
tagstr = "rt_reqpos=reqpos_centerscr rtfi_flags=freqf_patgad rtfi_matchpat=~(#?.xsrc)"
fullname = rtfilerequest(path,today,"SELECT Diary Entry ...",,tagstr)
if abbrev(fullname,path) = 0 then exit
entry = delstr(fullname,1,length(path))
password = rtgetstring(,,"Please Enter Password")

newwindow
IF exists(fullname) THEN DO
    xcom = 'execute (copy' fullname 't:temp)'
    xcom
    xcom = 'execute (xpack t:temp password "' || password || '")'
    xcom
    newfile "t:temp"
    chfilename fullname
    call delete("t:temp")
    IF entry < today THEN DO
        viewmode on
    END
    ELSE DO
        (bottom downadd return)
        C = "printf ((((((  %s  ))))))" time(c)
        C
        (justify center downadd downadd col 9)
    END
END
ELSE DO
    C1 = "insert (The Diary of" name "for" date(w) date(n) ")"
    C2 = "printf ((((((  %s  ))))))" time(c)
    C1
    (justify center downadd downadd)
    C2
    (justify center downadd downadd col 9)
    chfilename fullname
END
C = "settvar method IDEA settvar password" password
C
