| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | sched.btm - dayboot replacemnt |
Hi All.
recently I was aked to modify dayboot to allow a task to be schedules for
the same day of every month... looking at the source I could see no easy
way to add that feature while maitaining all the other features and keeping
the code tidy, So I ripped its guts out and started again.
as a result the data file is different... but it's got a half dozen new
capabilities and should be easier to extend....
I guess now I've put myself in the front-line for change requests.... :)
anyway here's it is...
:! SCHED.BTM VERSION 1.0 dec-2003
:!
:! Sched is by Jasen Betts, it is based on a btm program called Dayboot
:! which was developed by Gerald Miller and Jasen Betts which was based
:! on a btm pprogram by Klaus Meinhard called xbootex
:!
:! Gerald Miller Jasen Betts Klaus Meinhard
:! Fidonet 1:342/512 Fidonet 3:640/1042 Brahmsstr. 12
:! G 26842 Ostrhauderfehn
:! jasen_betts{at}f1042. Germany
:! n640.z3.fidonet.org Compuserve 100115,2025
:!
:!
:: lines containing : and ! together appear in the "help" listing
:: they may occur anywhere in this file.
:!
:! this is not the dayboot.btm you've used before
:!
:! THE DATA FORMAT IS DIFFERENT
:!
:! you will have to hand-edit the file to to new format
:! it's not that hard to do, see the notes below for copnverting
:! dayboot rules to Sched rules.
:!
:!
:!
:! S C H E D U L I N G R U L E S
:!
:!
:! Pnn periodical every nn days
:! tries to have exactly nn days between runs compensates for late
:! runs
:! (this is like the "plus rule" of dayboot except for
+365 and +366)
:!
:! Wnn Wait nn days
:! runs after nn days have elapsed
:! (this is the normal dayboot behavior)
:!
:! Dnn day-of-month
:! runs only on day NN of the month
:! negative numbers count from the end of the month
:!
:! Mnn month
:! runs only during month nn (can list multiple months)
:! (a combination of D and M rules nay be an apropriate replacemnt
:! for a +365 dayboot rule)
:!
:! A ask
:! prompt confirmation before running
:! (this is the ASK=YES of dayboot)
:!
:! Rnn random
:! run with nn% probability
:!
:! Nn Day of week
:! only run on the given days of the week, multiple day-numbers
:! may appear after the N
:!
:! O Option
:! this rule causes the contents of the
:! program name field to be ised to set program options
:! setting an option only effects the lines below it.
:!
:!
:! S O M E E X A M P L E R U L E S
:!
:! Description Rule
:!
:! JB's birthday M6D27
:! first day of each season M3M6M9M12D1
:! once a week P7
:! weekdays N12345
:! again after 4 days W4
:! 20 percent of the time R20
:! first monday of the month D1D2D3D4D5D6D7N1
:! first weekday of the month D1D2D3D4D5D6D7N12345W7
:! last sunday of the month d-1d-2d-3d-4d-5d-6d-7n0
:! always use this option O
:! this option on sunday only ON0
:!
:!
:! Documnted Options
:!
:! SILENCE=Y - never beep before asking (rule A)
:! SILENCE=1 - beep before the first ask only
:! RAPID=x - don't delay after running progs (anything for "x")
:!
:! (other options could have effects but theey probably
:! won't be desirable effects)
:!
:!
:!
:! INVOOCATION
:!
:! Call SCHED.BTM from your autoexec.bat.
:!
:!
:!
:! CONVERTING FROM DAYBOOT
:!
:! create a new shaed.dat file and append the dayboot.dat file to it
:! (copy sched.dat+dayboot.dat)
:! then edit the file to fix the fields up.
:!
:! the last-run and program name fileds can stay the same
:! (but the programs name field is now wider) the after-days field has been
:! repalced by the rules field, the other fields are no longer present -
:! the program didn't use them anyway
:!
:! nnnn the normal dayboot after_days rule is the W rule
:! so repalce nnnn in after_days with Wnnnn in RULE
:! +nnn the +nnnn rule is now the P rule (use Pnnnn)
:! +365 the +365 / +366 rules no longer exist use instead a
:! combination of the M ans D rules (like the example JB's Birthday)
:!
:!
:!
:! 4DOS VERSION COMPATIBILITY
:!
:! This .BTM was created and tested for use with 4DOS version 6.02B.
:! and version 7.02A it will not work with earlier versions of 4dos.
:!
:!
:!
:! LEGAL STUFF
:!
:! As far as I am able to determine the software that this program is
:! based on was in the public domain, all the bits I wrote are also.
:!
:! As a user you are responsible for determining the usefullnes for any
:! particular purpose of this software.
:!
:! This is free software as such you are entilteld to a full refund of the
:! purchase price if you are not completely satisfied :)
:!
:! if it breaksyou get to keep the pieces.
:!
:! Enjoy!
:START
*setlocal %+ *unalias *
break on
on break goto END
if "%temp" eq "" set temp=C:\
:: Next command establishes the location of the variable "BOOTFILE"
:: (btm_name.DAT) [should be in the same directory as this BTM file...]
set bootfile=%{at}path[%{at}search[%0]]%{at}upper[%{at}name[%0]].DAT
:: Next command establishes the location and name of the variable
:: "TEMPFILE" that holds the temporary file information while the
:: action is performed.
set tempfile=%{at}unique[%temp]
:: User input
if [%1]==[-?] .or. [%1]==[/?] .or. [%1]==[?] .or. %=
[%1]==[-h] .or. [%1]==[/h] .or. [%1]==[h] .or. %=
[%1]==[-H] .or. [%1]==[/H] .or. [%1]==[H] goto USAGE
:: df is local date format.
set df=%{at}replace[2,D,%{at}replace[20,YY,%{at}replace[1,M,%{at}makedate[14936]]]]
if "%1"=="HELP" .or. "/HELP"=="%1"
.or. "%1"=="-HELP" %=
( *ffind /VMKT"%{at}char[58]!" %_BATCHNAME | *list %+ goto usage )
:: Is the file SCHED.DAT there?
iff not exist %bootfile then
if [%1]==[DATAFILE] .or. [/DATAFILE]==[%1] .or. [%1]==[-DATAFILE] %=
( set tempfile=%bootfile %+ gosub tempfile %+ goto fin )
echo.
color bri red on bri whi
echo ERROR: %{at}path[%{at}search[%0]]%{at}upper[%{at}name[%0]].DAT was not found!
echo do "%0 datafile" to create a new (empty) one
color bri cya on bla
echo. %+ pause
goto fin
endiff
if [%1]==[DATAFILE] .or. [/DATAFILE]==[%1] .or. [%1]==[-DATAFILE] %=
( echo Not overwriting %bootfile - it already exists %+ goto fin )
:: Set variables. If DAYBOOT1 did it's job today already or it's before
:: 00:01 am, do nothing. In this case, the "start" time is 00:01 am....
:: Change the %do_time variable to suit your requirements.
set lastdate=%{at}date[%{at}filedate[%bootfile]]
set today=%{at}date[%_date]
set do_time=00:01
iff %{at}eval[%lastdate - %today] eq 0 .or. %{at}eval[%{at}time[%_time] - %=
%{at}time[%do_time]] le 0 then
echo. %+ echo.
color bri red on bri whi
echos There is nothing to do today because it's all been done!
color bri cya on bla
echo.
goto fin
endiff
:: Read DAYBOOT1.DAT, look at which programs to run today, copy info to
:: UNIQUE.TMP and update DAYBOOT1.DAT
set i=0
echo.
gosub tempfile
echo PATH\PROGRAM TO RUN ³LAST RUN³ RULE >%tempfile
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅ%df%ÅÄÄÄÄÄÄÄÄÄ >> %tempfile
set orig=%{at}instr[46,8,%{at}line[%bootfile,1]]
iff %orig == %df then
set dateconversion=%%date
else
:: Build a date conversion expression in a variable...
set dateconversion=%=
%%{at}instr[%{at}index[%orig,%{at}instr[0,2,%df]],2,%%date]%{at}instr[2,1,%df]%=
%%{at}instr[%{at}index[%orig,%{at}instr[3,2,%df]],2,%%date]%{at}instr[5,1,%df]%=
%%{at}instr[%{at}index[%orig,%{at}instr[6,2,%df]],2,%%date]
echo.
echo Converting date format from %orig to %df using expression:
echo.
set dateconversion
endiff
unset orig df
set MONTHDAYS=33-%{at}day[%{at}makedate[%{at}eval[%{at}date[%_DATE]-%{at}day[%_DATE]+33]]]
set MONTHDAYS=%{at}eval[%MONTHDAYS]
:: number of days in this month - used for negatives in the D rule
do n=2 to %{at}lines[%bootfile]
set prog=%{at}instr[0,45,%{at}line[%bootfile,%n]]
set RULES=%{at}instr[55,,%{at}line[%bootfile,%n]]
:: Convert last to local format
set date=%{at}instr[46,8,%{at}line[%bootfile,%n]]
set last=%dateconversion
if "%prog" == "" iterate
unset /q R V RULE_ RULE_P RULE_W RULE_D RULE_M RULE_A RULE_R RULE_N RULE_O
set RULE=%RULES%.
do while "%RULE" ne ""
set X=%{at}instr[0,1,%RULE]
set RULE=%{at}instr[1,99,%RULE]
iff "%X" == "" then
elseiff %{at}index[+-0123456789,%x] ne -1 then
set V=%V%%X
else
if "%V" == "" set V=0
if "%[RULE_%R]" ne "" set V= %V
set RULE_%R=%[RULE_%R]%V
set V=
SET R=%X
endiff
enddo
if %RULE_ == 0 set RULE_=
unset /q X V R
set RUNDATE=%_DATE
gosub interpret_rules
echo %{at}format[-45.45,%prog]³%{at}format[-8.8,%last ]³%RULES>>%tempfile
unset/q prog RULES RUNDATE LAST
unset /q R V RULE_ RULE_P RULE_W RULE_D RULE_M RULE_A RULE_R RULE_N RULE_O
enddo
unset/q next,
move/q/u %tempfile %bootfile >& nul
iff "%ITEM" gt "0" then
do m=1 to %ITEM
echo. %+ echo.
color bri whi on whi
echos %{at}upper[%0] Program Execution:
color bri cya on bla
echo %{at}upper[%[run%m]]
echo.
call %[run%m]
{at}echo off
enddo
endiff
echo.
color bri red on bri whi
echos %{at}upper[%0] END
color bri cya on bla
echo.
:END
color bri cya on bla
if "%item" ne "" if "%RAPID"=="" delay 5
if exist %tempfile del/q %tempfile > nul
:fin
endlocal
color bri cya on bla
quit
:interpret_rules
:: Implementation of the rules
::
:: note for programmers:
:: don't use shortcuts like %_DOW %_DAY %_MONTH, insteead use an expression
:: of _DATE like %{at}DOW[%_DATE] that way SET _DATE=... can be used for
:: debugging purposes instead of fiddling with the system date...
iff "%RULE_W" gt "0" then
if %{at}eval[%today-%{at}date[0%last]] lt %{at}word[0,%RULE_W] return
endiff
iff "%RULE_P" gt "0" then
if %{at}eval[%today-%{at}date[0%last]] lt %{at}word[0,%RULE_P] return
if "%last" ne "" set RUNDATE=%{at}makedate[ %{at}eval[
%{at}date[%last] + %=
( %today - %{at}date[%last] ) \ %RULE_P * %RULE_P] ]
endiff
iff "%RULE_R" gt "0" then
set RULE_R=%{at}word[0,%RULE_R]
if %{at}random[0,99] ge %RULE_R return
endiff
iff "%RULE_D" ne "" then
for D in (%RULE_D) do set X=%X %{at}IF[%d gt 0,%d,%{at}eval[%D+1+%MONTHDAYS]]
if %{at}index[ %X , %{at}DAY[%_DATE] ] == -1 return
endiff
iff "%RULE_M" gt "0" then
if %{at}index[ %RULE_M , %{at}MONTH[%_DATE] ] == -1 return
endiff
iff "%RULE_N" ne "" then
if %{at}index[%RULE_N,%{at}EVAL[(2+%TODAY) %% 7]] == -1 return
endiff
iff "%RULE_A" ne "" then
iff "%SILENT" ne "Y" then
beep 294 2 330 2 277 2 294 2 330 2 277 2 294 2 330 2 277 2 294 2
beep 330 2 0 2 139 2 165 2 196 2 233 2 277 2 466 2 554 2 659 2
beep 784 2 932 2
endiff
if "%SILENT" == "1" then set SILENT=Y
scrput %_row %{at}eval[17+%{at}len[%prog]] bri yel on bla `Y`
inkey /c/K"YN[esc][enter]" `Execute `%{at}upper[%prog]` [Y/N] ?` %%X
echo. %+ echo.
if not "%X" ne "Y" .and. "%X" ne
"{at}28" return
endiff
iF "%RULE_O" ne "" ( set %prog %+ goto nilrun )
set item=%{at}inc[%item]
set run%item=%prog
:nilrun
set last=%RUNDATE
:norun
return
:tempfile
:: 0123456789012345678901234567890123456789012345678901234567890
echo PATH\PROGRAM TO RUN ³LAST RUN³ RULE >%tempfile
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅ%df%ÅÄÄÄÄÄÄÄÄÄ >>%tempfile
return
:USAGE
color bri cya on bla
text
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ SCHED Once a day program execution with many options ³
³ (selectable intervals, ask before execution). ³
³ For more info see the header of this file. ³
³ ³
³ SCHED.DAT is the data file for SCHED.BTM, ³
³ where you can enter your progs and parameters. ³
³ It _must_ be in your path or the root dir of ³
³ your boot drive. ³
³ ³
³ SCHED should be CALLed from autoexec.bat ³
³ or executed atleast once daily in some other way³
³ ³
³ Optional parameters: ³
³ ³
³ (none) run tasks as described above ³
³ /H /? (etc) show this message ³
³ DATAFILE create a blank data file ³
³ ³
³ HELP view the program notes, history and rule help ³
³ (many pages of help) ³
³ ³
endtext
echos À%{at}repeat[Ä,73]Ù
goto fin
-=> Bye <=-
---
* Origin: Black Holes were created when God divided by zero! (3:640/1042)SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.