home *** CD-ROM | disk | FTP | other *** search
- Task Macro - A {COMMO} timed execution facility
- Copyright (c) 1992 Joe Hayashi
-
- {:start} ;Begin here
- ;Process one-time setup stuff
- {sete-p quit} ;What to do when you press <esc>
- {setv %day,0} ;Set day counter to zero
- {setv %quitcommmand%,quit} ;Command for tasker to quit
- ! {setv schedulefile,c:\commo\task.txt} ;Name of schedule file
- {setv dayoffset,%_dwn%} ;Variable used in reading
- {incr dayoffset,5} ; the task file
- {setlook 15,checktime} ;Check time every 15 seconds
- ! {capt y,c:\commo\task%_mon%%_day.log} ;Save log file of what happened
- {display ,,,^m^j TASKER fired up on %_dwt%, %_tim%, %_dat%.^m^j}
- {display ,,,^m^j Later dude!^m^j}
- {:main}
- {call schedulesetup} ;Repeated init stuff
- {call loop} ;Workhorse loop
- {goto quit} ;See ya!
- {}
- ;Shared functions
-
- {:quit} ;Exits program
- {rclose}
- {display ,,,^m^j TASKER quit on %_dwt%, %_tim%, %_dat%.^m^j}
- {exit}
- {}
-
- {:retu} {return} {} ;Lets gotos return to a caller
-
- ;Init stuff each time the schedule file is read
- ; and process this stuff for the "new" day
- {:schedulesetup}
- {beep} {display ,,, Ho hum.^m^j}
- {incr %day%} ;# of days running
- {incr %dayoffset%} ;Increment offset variable
- {comp %dayoffset%,13} ;Make sure offset var has not
- {ifco-g endofweek,} ; gone past Sunday
- {:weekhurdle}
- {ropen %schedulefile%,main}
- {return}
- {}
- ;schedulesetup functions
- ;endofweek - resets the variable that measures the offset
- ; from the beginning of each line in the command file
- {:endofweek}
- {setv dayoffset,7} ;Reset var to Monday position
- {goto weekhurdle} ;Return to schedulesetup
- {}
-
- ;processline - this function sets up the variables used in
- ; loop to process tasks. It checks first to see if the
- ; current line is to be executed today, if it is then it
- ; read the time and compares it to the current time. This
- ; lets the program skip task times which have already
- ; passed when you begin the program. Finally it reads the
- ; task it is to execute and returns control to the loop.
- {:processline}
- {call getline} ;Read an entire line into %line%
- {subs dotoday,%dayoffset%,1,%line%} ;Look for a " " in today's
- {comp dotoday, } {ifco processline,} ; location, if found skip line
- {subs nexthour,1,2,%line%} ;Read hours
- {subs nextmin,4,2,%line%} ;Read minutes
- {setv nextcomp,%nexthour%%nextmin%} ;Var to compare to current time
- {setv now,%_24h%%_min%} ;Make current military time var
- {comp %now%,%nextcomp%} ;Check if task time has passed
- {ifco-g firstday,} ;
- {:continue}
- {subs nexttask,15,128,%line%} ;read command line of task
- {setv nexttime,%nexthour%:%nextmin%} ;Set nexttime var
- {return}
- {}
-
- ;functions used by processline
- ;getline - reads an entire line from the schedule file into
- ; the variable line, it ignores lines that are too short
- ; and ignores lines that begin with the comment character "#"
- {:getline}
- {read line}
- {inst line,#}
- {comp %_pos,1} {ifco getline,}
- {leng %line%}
- {comp %_len%,14} {ifco-le getline,}
- {setv _len,}
- {return}
- {}
- ;firstday - checks if program has just started today
- ; example: I start program at 6pm. There are no tasks until
- ; tomorrow (i.e. program reads to end of file). But when it
- ; finds the first task at 1am, we must process this task
- ; even though 6pm > 1am (this comparison is made above in
- ; processline).
- {:firstday}
- {comp %day%,1} ;compare to first day
- {ifco-g continue,processline} ;if not first day continue
- ; otherwise read next line
- {}
-
- ;loop - this is the main workhorse loop of program
- {:loop}
- {call processline} ;Get time & task, see above
- {display ,,,^m^j Issuing: %nexttask%^m^j} ;Bother user
- {display ,,, at: %nexttime%^m^j}
- {:wait}
- {calook checktime,phonecall,RING} ;look for RINGs
- {lookfor Godot.}
- {:checktime}
- {setv now,%_24h%%_min%} ;Make current military time var
- {comp %nextcomp%,%now%} ;Compare times
- {ifco ,wait} ;If equal, continue, else wait
- {comp %nexttask%,%quitcommand%} ;Check if command is to quit
- {ifco retu,} ;If so, quit
- {call exectask} ;Otherwise execute task
- {display ,,,^m^j Command: %nexttask%^m^j} ;Bother user again
- {display ,,, returned: %_err%^m^j^m^j}
- {goto loop} ;Re-loop
- {}
-
- ;exectask - executes a command line & returns to caller
- {:exectask} {exec-w60 %nexttask%} {return} {}
-
- ;phonecall - what to do when the phone rings, you could,
- ; for instance, load host macros, go into host mode, and
- ; answer the phone if you were so inclined, I just record
- ; the time
- {:phonecall} {display ,,, at %_24h%:%_min%^m^j} {return} {}
-