home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 3
/
Meeting_Pearls_III.iso
/
Pearls
/
text
/
FAQ
/
bonus
/
faq_setdate_byKL.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-10-07
|
2KB
|
88 lines
/* ARexx script
for :Pearls/text/FAQ on CD "Meeting Pearls III"
- setting date with date keyword
- renaming to archive name keyword
$VER: faq_setdate_byKL.rexx 0.3 (18.09.95) ©1995 Khamsonh Marcel Khounlivong
*/
OPTIONS RESULTS
PARSE ARG keylist destination
keylist = Strip(keylist)
destination = Strip(Strip(destination),t,'/') || '/'
dates = "Date:"
string = ""
months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
days = "Mon Tue Wed Thu Fri Sat Sun"
IF (destination == "/") THEN DO
SAY "faq_setdate_byKL.rexx ©1995 Khamsonh Marcel Khounlivong"
SAY "use:
[rx] faq_setdate_byKL[.rexx] keylist destination
"
EXIT 0
END
CALL AddLib("rexxsupport.library",5,-30)
IF (~Open(infile,keylist,r)) THEN DO
SAY ''keylist 'not exists'
EXIT 20
END
DO FOREVER
line = ReadLn(infile)
IF (line == "") THEN DO
CALL Close(infile)
EXIT
END
arcname = destination || Word(line,1)
IF (~Open(file,arcname,r)) THEN DO
SAY ''arcname "can't open"
EXIT 20
END
date = ""
CALL scan_word
CALL scan_word
CALL Close(file)
IF (date == "") THEN DO
SAY ''arcname "missing date"
EXIT 20
END
CALL set_date
END
scan_word:
DO UNTIL (string ~= "")
string = ReadLn(file)
END
DO WHILE (string ~= "")
string = Translate(string,' ','09'x)
IF (date ~= "") THEN LEAVE
IF (Find(dates, Strip(Word(string,1))) ~= 0) THEN
date = SubStr(string,WordIndex(string,2))
string = ReadLn(file)
END
RETURN
/* setting date by overwriting download time with
header informations */
set_date:
/* there's a format starting with weekday */
IF (Find(days,Strip(Word(date,1),,',')) ~= 0) THEN
date = SubStr(date, WordIndex(date,2))
day = Word(date,1)
month = Right(Find(months,Word(date,2)),2,'0')
year = Right(Word(date,3),2)
our = Word(date,4)
newdate = day || '-' || month || '-' || year our
ADDRESS command 'setdate' arcname newdate
IF (RC ~= 0) THEN EXIT 20
RETURN