Just a sample of the Echomail archive
Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.
|    BATPOWER    |    Batch Language Programming    |    216 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 57 of 216    |
|    Richard Webb to all    |
|    another convoluted brainteaser for the g    |
|    12 Jan 12 13:15:51    |
      Hello all!                     Some of you batch gurus will be able to point out some       pitfalls I've missed, but let me explain first what this is       about.              I email out a little weekly journal newsletter to a group of ham radio folks I       work with, our common interest assisting       vessels at sea, folks serving their country or faith abroad, etc.              One thing I've always wanted to implement was a bit of a       history section, keyed by date. These go out on Sunday       mornings, of course.              This batch would run at midnight utc on Sunday of course adn prepare the       history information, compiling into it a file       that the weekly email generator code would find.              So, taking this Sunday's for example, the batch would look       in a defined directory for files named 0115.txt; 0116.txt; 0117 ... etc.              Easy enough done, stuff number of month and day into an env       var called %NEWS% using HOrst's logecho.       OF course I'm using HOrst's nset and count, as well as       ifnumber in this thing.              The first thing we need to do is see if the date's getting       toward roll over to next month.       That one's easy. Check if day of the month is 22 or       greater.              IF the date is 22 or greater we then need to create a       "turnover" file which will be used to create another       environment variable.              So here's how we're accomplishing that so far. the fun       comes once we've defined all this.       We start the set up for it to do its beautiful work like       this:                     :: 300hist.bat       @echo off       :: desc: This batch is under construction       :: desc: function: Runs on Sundays 0000 utc or is triggered at that time. ::       desc: helps us grab historic trivia for weekly journal       logecho $D | nset starter=$1       set checker=22       ifnumber %STARTER% biggerequivalthan %CHECKER > nul       if errorlevel 1 goto workit       :: if starter is bigger or equal to checker we may need to       :: turn over to a new month. IF not, we just cruise along.                     set starter=       set checker=       goto regular       :workit       set starter=       set checker=       logecho $M | nset bump=$1       :: now we use HOrst's count to add one.              count BUMP +1       set checknum=10       :: environment variables are stored ignoring leading zeroes       :: unless you stuff them in. So we set checker to 10 and       :: test for smaller than, because if %BUMP% os a somg;e       :: digit we need to add a zero.       :: we're going to create a file to use to capture       :: data for the environment variable at turnover of month.       ifnumber %BUMP% smallerthan %CHECKNUM% > nul       if errorlevel 1 goto addzero       goto doit       :addzero       set checknum=       echo 0%BUMP%01 >> bumper.txt       set bump=       goto workout       :doit       set checknum=       echo %BUMP%01 >> bumper.txt       set bump=       goto workout       :workout       cd \working                     :: now we see how many days are in the current month, so       :: that we turn over at the appropriate place utilizing the       :: file bumper.txt we created to set the new %NEWS%       :: env var for the appropriate day's history capture.       :: we already have repnum.txt with the data inside. HEnce:       nset repnum=$1 |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca