Subj : Daynbr
To   : Dallas Hinton
From : mark lewis
Date : Tue Aug 28 2012 11:54 am


DH> Thanks, Mark -- no, it has to be Windows 32/64 bit.

ml> hummm... may i ask why? a limitation of the OS' console operations?
ml> i don't know how far 4DOS/4OS2/4NT has gone but there may be a 32bit
ml> build of them...

DH> It's what I run on my desktop. Simple!

:)

ml> ahhh... other than a simple DOY tool? ;)

DH> If we change to something other than daynbr, then several batch
DH> files will have to be rewritten -- rather a pain!

i know what you mean about "fixing" a working system...

ml> drawback is that daynbr is a shell program... by that i'm meaning
ml> that it does the doy calcs and formatting on the @### items found on
ml> the command line and then it shells out to another console to do the
ml> actual work and feeds that math @### calculation to the shelled task
ml> in the same manner that i was thinking of just setting an
ml> environment variable to the needed doy variable...

DH> There's several routines for getting that number, but as I say, a
DH> complete rewrite of the existing batch files.

hummm... bear with me... this is kinda a "stream of consciousness" flow...

[current DoY]

C:>daynbr echo @###
DAYNBR -- Version 1.0
Copyrignt (c) 1985 by Ben Baker
Released for noncommercial distribution

Executing 'echo 241'

241

C:>echo %_doy
241

[DoY seven days ago]

C:>daynbr /-7 echo @###
DAYNBR -- Version 1.0
Copyrignt (c) 1985 by Ben Baker
Released for noncommercial distribution

Executing 'echo 234'

234

C:>echo %@EVAL[%_DOY-7]
234

so those are relatively easy general DoY things... however, figuring the DoY
for a specific weekday like a sunday or a friday may slightly more complicated
depending on what you want or need to do... hummm... check this created on the
fly monstrousity... it looks complicated but it isn't as bad as it looks... the
following is all one long line but i'll break it apart here for easier
reading...

for %i in (-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7) do echo
%@IF[
 '%@DOW[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]]' EQ 'Fri',
   %@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]] is a
     %@DOW[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]] YaaY!!! DoY =
       %@DOY[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]],
   %@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]] is a
     %@DOW[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]] Booo...
]

i'm using the %@IF[condition,true,false] function and the true and false stuff
is the same so as to print the calculated date and day... their deviation comes
at "YaaY!!!" or "Booo..." plus the true result (YaaY!!!) prints the DoY for
that date... this all wrapped in a simple FOR loop feeding the numbers into the
%i variable to subtract or add X to today's date... to do that we have to work
with the number of days since the epoch date of 01-01-80 so that's why there's
all that messy MAKEDATE stuff in there... it gets easier further below ;)

the output is...
08-21-12 is a Tue. Booo...
08-22-12 is a Wed. Booo...
08-23-12 is a Thu. Booo...
08-24-12 is a Fri. YaaY!!! DoY = 237
08-25-12 is a Sat. Booo...
08-26-12 is a Sun. Booo...
08-27-12 is a Mon. Booo...
08-28-12 is a Tue. Booo...
08-29-12 is a Wed. Booo...
08-30-12 is a Thu. Booo...
08-31-12 is a Fri. YaaY!!! DoY = 244
09-01-12 is a Sat. Booo...
09-02-12 is a Sun. Booo...
09-03-12 is a Mon. Booo...
09-04-12 is a Tue. Booo...

so we can mimic daynbr's /Dx where x is 0 thru 6... with a similar "formula"
(wow... never would have thought of it as a formula but i guess that is what it
is) using the DoWI function and/or variable... so the condition in the above
would use the DoWI function and go from this

'%@DOW[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]]' EQ 'Fri'

to this

'%@DOWI[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]]' EQ '6'

but that's one (1) based... if we want it zero (0) based like daynbr, then we
need an @EVAL[] wrapped around that to subtract one (1) from the result and
then drop the 6 back to 5 for the comparison...

'%@EVAL[%@DOWI[%@MAKEDATE[%@EVAL[%@DATE[%_date]+%i]]]-1]' EQ '5'

so... in this example, i've done a MAKEDATE of a date (today +- 0 thru 7) so we
can see what they were seven (7) days ago, today and seven (7) from today... we
calculate the DoWI (Day of Week Integer) on that date... then we subtract one
(1) from DoW Integer to zero (0) base it...

now here's a much shorter version without all the MAKEDATE date calculation
stuff needed to add or subtract a random X from a date... this one checks
today's DoWI _only_... it is zero (0) based like daynbr's is... again, broken
apart for readability but it is all one long line...

echo %@IF[
 '%@EVAL[%_DOWI-1]' EQ '5',
   %_date is a %@DOW[%_date]. YaaY!!! DoY = %@DOY[%_date],
   %_date is a %@DOW[%_date]. Booo...
]

08-28-12 is a Tue. Booo...


now that we can see the basics and how it may be used, we can do something
simple like this to work with today's info only ;)

rem see if today is friday via _DOWI. equal to daynbr /d5 some.bat @###
rem but here, we just set dodiff to the DoY or no vs calling some.bat
set dodiff=%@IF['%@EVAL[%_DOWI-1]' EQ '5',%@DOY[%_date],no]
if '%dodiff' eq '' goto errror
if '%dodiff' eq 'no' goto skipdiff
echo *** do nodediff stuffs here ***
:skipdiff
goto whereever
:error
echo oops! dodiff variable is not set :(
:whereever


ml> FWIW: everything, other than the new coding of an app for this, is
ml> all 16bit stuff... everything in BATPOWER that might help you seems
ml> to be but it is possible that i've overlooked something...

DH> That's the other possibility - batch files work, and maybe I can
DH> write a daynbr.bat to take the equivalent parameters.

does daynbr not run for you any more or is it the shelling to the called apps
that is failing??

BTW: what version of daybnr do you have?

)\/(ark


* Origin:  (1:3634/12)