Category : Batch File Utilities - mostly for DOS
Archive   : DATECHEK.ZIP
Filename : DATECHEK.BAS

 
Output of file : DATECHEK.BAS contained in archive : DATECHEK.ZIP
'Tues Jan 2, 1990 6:36:59 pm
'
'*************************************************************************
'DATECHEK checks the current date to perform periodic operations. v1.1
'See HELP subroutine for syntax and details.
'by David Wesson 24 Fairview St. W.Hartford, CT 06119 230-523-1873
'*************************************************************************

'$INCLUDE: 'qb4bas.bi'

DECLARE SUB help ()
DECLARE SUB readcommandline ()
DECLARE SUB getdatefile ()
DECLARE SUB selectoption (value)
DECLARE SUB operation (value)

CONST yes = 0, no = 1

COMMON SHARED savedate, match, today
DIM SHARED comstr$(11), period$(11)

'------------------------ MAIN PROGRAM BEGINS HERE -----------------------
readcommandline
getdatefile
DO WHILE NOT comstr$(x + 1) = ""
x = x + 1
selectoption x
operation x
LOOP
OPEN "DATEFILE" FOR OUTPUT AS 2
PRINT #2, QDATE("J")
CLOSE 2
QEXIT match
'------------------------- MAIN PROGRAM ENDS HERE ------------------------

SUB getdatefile
IF QEXIST("DATEFILE" + CHR$(0)) = yes THEN
OPEN "DATEFILE" FOR INPUT AS 1
INPUT #1, savedate
CLOSE 1
ELSE
savedate = VAL(QDATE("J"))
END IF
END SUB

SUB help
CLS
PRINT "DATECHEK checks the current date to perform periodic operations."
PRINT "If the date criteria is met, a command string is activated, and"
PRINT "a message with a time and date stamp is written to a file called "
PRINT "DATECHEK.LOG for reference. In all cases, an errorlevel is set."
PRINT ""
PRINT "SYNTAX: DATECHEK period commandstring ! period commandstring . . ."
PRINT " where period = EVERY, DAILY, MON, TUE, WED, THU,"
PRINT " FRI, SAT, SUN, FIRST, LAST, MID"
PRINT " commandstring = command to be executed (no quotes)"
PRINT " ! = delimiter for multiple operations (10 max)"
PRINT ""
PRINT "PERIOD DESIGNATIONS EXIT ERRORLEVELS"
PRINT " EVERY = Every Log On (For last operation only)"
PRINT " DAILY = Each Day, first Log On only 0 = Date matched"
PRINT " MON, TUE, WED, THU, FRI, SAT, SUN 1 = Date not matched"
PRINT " = Every Monday, Tuesday, etc. 2 = No commandline"
PRINT " FIRST, MID, LAST 3 = Commandline error"
PRINT " = Every First, Fifteenth, "
PRINT " or Last Day of the month"
PRINT ""
PRINT "DATECHEK v1.1"
PRINT "by David Wesson 24 Fairview St. W. Hartford, CT 06119 203-523-1873";
END SUB

SUB operation (x)
IF match = yes THEN
OPEN "DATECHEK.LOG" FOR APPEND AS 1
PRINT #1, QDATE("N"); SPACE$(2); TIME$; SPACE$(2); "DATACHEK performed "; LTRIM$(comstr$(x))
CLOSE 1
SHELL comstr$(x)
END IF
END SUB

SUB readcommandline
inline$ = COMMAND$
IF inline$ = "" THEN help: QEXIT 2
DO
x = x + 1
IF inline$ = "" THEN EXIT DO
period$(x) = QWORD(inline$, 1)
inline$ = LTRIM$(MID$(inline$, LEN(period$(x)) + 1))
y = 0
DO
y = y + 1
word$ = QWORD(inline$, y)
IF word$ = "" THEN inline$ = "": EXIT DO
IF LEFT$(word$, 1) = "!" THEN
inline$ = LTRIM$(MID$(inline$, INSTR(inline$, "!") + 1))
EXIT DO
ELSE
comstr$(x) = comstr$(x) + SPACE$(1) + word$
END IF
LOOP
LOOP
END SUB

SUB selectoption (x)
today = VAL(QDATE("J"))
match = no
period$(x) = LEFT$(period$(x), 2)
IF today = savedate AND NOT (period$(x) = "EA" OR period$(x) = "EV" OR period$(x) = "AL") THEN EXIT SUB
SELECT CASE period$(x)
CASE "EA", "EV", "AL"
match = yes
CASE "DA", "ON"
IF today > savedate THEN match = yes
CASE "MO", "TU", "WE", "TH", "FR", "SA", "SU"
IF UCASE$(LEFT$(QDATE("W"), 2)) = LEFT$(period$(x), 2) THEN match = yes
CASE "FI"
IF (VAL(LEFT$(QDATE("E"), 2))) = 1 THEN match = yes
CASE "MI"
IF (VAL(LEFT$(QDATE("E"), 2))) = 15 THEN match = yes
CASE "LA"
IF VAL(LEFT$(QDATEIN(STR$(today + 1), "U"), 2)) > VAL(LEFT$(QDATE("U"), 2)) THEN match = yes
CASE ELSE
match = 3
END SELECT
END SUB



  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : DATECHEK.ZIP
Filename : DATECHEK.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/