TIP: Click on subject to list as thread! ANSI
echo: 4dos
to: All
from: Jasen Betts
date: 2003-09-09 19:01:54
subject: new version of dayboot

Hi All.

Gerald asked me to look at this for him earlier and I tweaked a few things.
he also asked me tyo post it here.

enjoy.


=== Cut Begin: DAYBOOT1.BTM ===
::  DAYBOOT1.BTM                             VERSION 1.35  Aug-31-2003
::                                                            01:35:00
::  (Once a day program upon boot execution)
::
::  by                                          Gerald Miller
::                                              Fidonet 1:342/512
::  and                                         Jasen Betts
::                                              Fidonet 3:640/1042
::
::  based on the original XBOOTEX.BTM by        Klaus Meinhard
::                                              Brahmsstr. 12
::                                              G 26842 Ostrhauderfehn
::                                              Germany
::                                              Compuserve 100115,2025
::
::  For those of you who have more extensive needs than can be filled by
::  XDAILY.BTM (DAILY.BTM), here is a utility that allows you a very
::  versatile handling of programs you want to run only once a day at
::  first boot time.
::
::  DAYBOOT1 allows you to specify as many programs as you wish in the
::  data file DAYBOOT1.DAT, with an interval in days for running each
::  program and the possibility to ask if the program should be run
::  (nice if you do not have the time for it just then).  You will be
::  asked again the next day if you skip.
::
::  If you want to run another batch file, enter `c:\path\mybatch`
::  in DAYBOOT1.DAT to insure the return to DAYBOOT1.BTM after execution.
::  If your program (batch file) is on the path, you may omit the
::  pathname.
::
::  So, maybe you want to run STACKER's CHECK every day, but a virus
::  scanner only once a week, and defrag once a month?  No problem,
::  just fill in those programs in DAYBOOT1.DAT with the appropriate
::  parameters.  Just be careful not to change the formatting of that
::  file, because DAYBOOT1.BTM depends on it.
::
::  There is an example data file (DAYBOOT1.DAT) which shows the working of
::  all this and makes calls to five BTM files [one, of which, is included
::  as a working example] to show you how DAYBOOT1 works.
::
::  Some of the NEXT RUN date field and DAYS LEFT field within the
::  DAYBOOT1.DAT file are "zeroed" out on the theory that the first time
::  you execute the DAYBOOT1.BTM, all the fields should contain the
::  "correct" data upon completion.
::
::  The five "simple" BTM files all echo their name to the screen and
::  "touch themselves" when called upon based on the information contained
::  in the data file.  (The date and time stamp of the five BTM files will
::  change based on execution.)
::
::  Call DAYBOOT1.BTM from your autoexec.bat.  DAYBOOT1.DAT _must_ be in
::  your path or the root dir of your boot drive!
::
::  This .BTM was created and tested using 4DOS version 6.02B (131).  THERE
::  IS NO 4DOS VERSION CHECKING BEING PERFORMED BY THIS .BTM!!!
::
::  ** Features fixed / added / pending:
::
::     - Removed all leading "_" characters from non-4DOS variable names to
::       avoid possible conflict of future 4DOS variable names.
::     - Calculate the date of a program's next call.
::     - Calculate the number of days remaining until the next call.
::     - Removed the necessity to have `CALL` within the data file (the
::       batch file now makes the CALLs to all programs/batch files)
::     - Implemented a date conversion routine to change the date format of
::       the data file to match that of the current user's system (ISO
::       format).  This action is done "on_the_fly" and need only be
::       performed once, but the beauty of this routine means that data
::       files can be exchanged between systems and operate correctly on
::       the first attempt.
::     - Calculate Leap Year data for occasions when a batch file or
::       program is called only once a year.
::     - added a different rule that compensates for missed days (gosub
::       schedule_prog); that rule is used when %when starts with a "+" so
::       if you want something done on Mondays, set %last to a Monday and
::       put +7 in the rule and it'll do it on Mondays and if you forget to
::       boot one Monday it'll do it on Tuesday instead like always but and
::       it will do it next on Monday again... it's also handy for
::       birthdays...
::
::  I recommend that all the CALLed batch files end with:
::
::      touch/q %_batchname
::
::  to serve as an indicator of when that batch file was last run.  I
::  ****DO NOT**** recommend that you use the touch command on
::  ****ANY**** executable (i.e.: *.COM, *.EXE, *.CMD, etc.) file!!!
::
::  Further suggestions welcome

:START
  *setlocal %+ *unalias *
  break on
  on break goto END
  if "%temp" eq "" set temp=C:\

::  Next command establishes the location of the variable "BOOTFILE"
::  (DAYBOOT1.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

::  Is the file DAYBOOT1.DAT there?  Where?
  iff not exist %bootfile then
    echo.
    color bri red on bri whi
    echos ERROR: %{at}path[%{at}search[%0]]%{at}upper[%{at}name[%0]].DAT was not found!
    color bri cya on bla
    echo. %+ delay 10
    goto END
  endiff

::  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
  set country=%_country

  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 END
  endiff

::  Read DAYBOOT1.DAT, look at which programs to run today, copy info to
::  UNIQUE.TMP and update DAYBOOT1.DAT
  set i=0
  echo.

::  df is local date format.
set df=%{at}replace[2,D,%{at}replace[20,YY,%{at}replace[1,M,%{at}makedate[14936]]]]

text>%tempfile
PATH\PROGRAM TO RUN                      ³AFTER³        ³        ³DAYS ³
                                         ³ DAYS³LAST RUN³NEXT RUN³ LEFT³ASK
endtext

echo ÄÄÄÄ %{at}format[03.3,%country] %{at}repeat[Ä,12] Time: %_time ÄÄÄÄÅ%=
ÄÄÄÄÄÅ%df%Å%df%ÅÄÄÄÄÄÅÄÄÄ >> %tempfile

set orig=%{at}instr[48,8,%{at}line[%bootfile,2]]

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

do n=3 to %{at}lines[%bootfile]
  set prog=%{at}instr[0,41,%{at}line[%bootfile,%n]]
  set when=%{at}instr[42,5,%{at}line[%bootfile,%n]]
::  Convert last to local format
  set date=%{at}instr[48,8,%{at}line[%bootfile,%n]]
  set last=%dateconversion
  set left=%{at}instr[66,5,%{at}line[%bootfile,%n]]
  set ask=%{at}instr[72,1,%{at}line[%bootfile,%n]]

  if "%prog" == "" iterate
  iff %{at}eval[%today-%{at}date[%last]] ge %when then
    iff "%ask" eq "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
      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] ?` %%ink
      echo. %+ echo.
      iff "%ink" eq "Y" .or. "%ink" eq
"{at}28" then
        gosub schedule_prog
      endiff
    elseiff "%ask" eq "N" .or. "%ask" eq
"" then
      gosub schedule_prog
    endiff
  endiff

  if "%when" == "" set when=.
  iff %when eq 365 .or. %when eq 366 then
::  LeapYear correction: try 366 days; if no good, use 365
    set when=+366
    set nxdate=%{at}makedate[%{at}eval[%{at}date[%last]+%when]]
    if %{at}day[%nxdate] ne %{at}day[%last] set when=+365
  endiff

    set nextdate=%{at}eval[%{at}date[%last] + %when]
    set daysleft=%{at}eval[%nextdate - %today]
    set nxdate=%{at}makedate[%nextdate]

   echo %{at}format[-41.41,%prog]³%{at}format[-5.5,%when]³%{at}format[-8.8,%last]%=
³%{at}format[-8.8,%nxdate]³%{at}format[-5.5,%daysleft]³%ask>>%tempfile
      unset/q prog daysleft nextdate nxdate when
  enddo
  unset/q next,
  move/q/u %tempfile %bootfile >& nul
    iff "%i" ne "0" then
      do m=1 to %i
        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
    delay 5
    if exist %tempfile del/q %tempfile > nul
    endlocal
    color bri cya on bla
    quit

:schedule_prog
  set i=%{at}inc[%i]
  set run%i=%prog
  iff "%{at}left[1,%when]" ne "+" then
    set last=%{at}makedate[%today]
  else
    set last=%{at}makedate[%{at}eval[%{at}date[%last]+%when]]
  endiff
return

:USAGE
    color bri cya on bla
    text
 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
 ³ DAYBOOT1  ÄÄÄÄÄÄÄ          Once a day program execution with many options  ³
 ³                            (selectable intervals, ask before execution).   ³
 ³                            For more info see the header of this file.      ³
 ³                                                                            ³
 ³                            DAYBOOT1.DAT is the data file for DAYBOOT1.BTM, ³
 ³                            where you can enter your progs and parameters.  ³
 ³                            It _must_ be in your path or the root dir of    ³
 ³                            your boot drive. (See the sample:               ³
 ³                                "Cut Begin: DAYBOOT1.DAT"      
            ³
 ³                            near the end of this BTM file.)                 ³
 ³                                                                            ³
 ³                            DAYBOOT1 should be _called_ from autoexec.bat   ³
 ³                                                                            ³
 ³ Syntax:  DAYBOOT1 /? -?    Syntax (this screen)                            ³
 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    endtext
    goto END

=== Cut Begin: DAYBOOT1.DAT ===
PATH\PROGRAM TO RUN                      ³AFTER³        ³        ³DAYS ³
                                         ³ DAYS³LAST RUN³NEXT RUN³ LEFT³ASK
ÄÄÄÄ 001 ÄÄÄÄÄÄÄÄÄÄÄÄ Time: 00:01:58 ÄÄÄÄÅÄÄÄÄÄÅMM-DD-YYÅMM-DD-YYÅÄÄÄÄÄÅÄÄÄ
STEP_0.BTM                               ³1    ³08-31-03³00-00-00³000  ³N
STEP_1.BTM                               ³1    ³08-31-03³00-00-00³000  ³N
STEP_2.BTM                               ³+7   ³08-31-03³00-00-00³000  ³Y
STEP_3.BTM                               ³+14  ³08-31-03³00-00-00³000  ³N
STEP_4.BTM                               ³+14  ³08-24-03³00-00-00³000  ³
birthday.btm /Addison                    ³+365 ³02-23-03³00-00-00³000  ³N
birthday.btm /Michael                    ³+365 ³03-06-03³00-00-00³000  ³Y
birthday.btm /Arlene                     ³+365 ³08-16-03³00-00-00³000  ³N
birthday.btm /Gerard                     ³+365 ³11-22-02³00-00-00³000  ³N
birthday.btm /Eileen                     ³+365 ³12-27-02³00-00-00³000  ³N
=== Cut End:   DAYBOOT1.DAT ===

The above sample .DAT file _should_ be able to be run on your system with
no evil consequences.

If your country code is different than "001", it will be replaced with your
current country code.

The time field will change to the time that you execute this .BTM.

The date fields will change in accordance to your country code.  For
example, if your country code is set for Australia, "001" will change to
"061" and the current date fields in the above example,
"MM-DD-YY" will
automatically change to "DD/MM/YY".  All the remaining dates in the above
sample .DAT file will be converted "on-the-fly" to the correct format as
reflected by your country code.

The Days Left field will be adjusted to the correct value *AFTER* you
execute this .BTM.

You may change the value in the Ask field; an empty expression (blank
character) in this field is presumed to be a "N".

I'll include a sample TEST batch file (STEP_0.BTM) and you can copy it to
the other four test files...

=== Cut Begin: STEP_0.BTM ===
echo. %+ echo    This is %{at}upper[%{at}name[%_batchname]]. %+ echo.
touch/q %_batchname
=== Cut End:   STEP_0.BTM ===

=== Cut Begin: BIRTHDAY.BTM ===
beep 262 3 262 1 294 6 262 6 349 6 330 15
beep 262 3 262 1 294 6 262 6 392 6 349 15
beep 262 3 262 1 523 6 440 6 349 6 330 6 294 15
beep 466 3 466 1 440 6 349 6 392 6 349 15
touch/q %_batchname
=== Cut End:   BIRTHDAY.BTM ===

As usual, I'm not responsible for any damages....  :-)
=== Cut End:   DAYBOOT1.BTM ===

           Cheers ... Gerald

 -=> Bye <=-

---
* Origin: One less than the checksum of "Jasen Betts" (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™.