Date:   Mon Oct 09 1995  12:02:00
From:   Bill Whitehouse
To:     bill jernigan
Subj:   head 'em off at the past!
Attr:   sent 
4dos_tc                        -------------------------------

According to bill jernigan (1:3615/57) on Sun, Oct 08 at 07:59:

 bj>this is exactly what i was looking for...but i don't 
 bj>understand how it works...

 BW> :sun
 BW> for %a in (sun mon tue wed thu fri sat) (set %a=%b^set b=%@inc[%b])

 bj>i discovered what this does (sets %a=sun and %b=7), but i don't know
 bj>why -- how does it get "7" out of "sun" + "1"?...

     It doesn't. Sun, in this case, assumes no value. All you're doing in the 
example above is: 

:sun
set mon=1
set tue=2
set wed=3
set thu=4
set fri=5
set sat=6
return

 BW> set %_dow=0

 bj>why set %_dow=0?...i didn't know you could even do this with an internal 
 bj>variable, and i sure don't understand why you would want to...

     Because it works? ;-) See, if today is Sunday, then all that amounts to 
is Sun=0. %_dow is unaffected. 

 bj>and this stuff...the first line give us a number, and i guess at this 
 bj>point "%sun"="7" (somehow), and it DOES work, but i would appreciate a 
 bj>lesson in 4dos here...can you explain it to me?...

 BW> set day=%@eval[%diff-(7*%@int[%@eval[%diff/7]])]
 BW>     if %day=%sun echo %1 %is a Sunday
 BW>     if %day=%mon echo %1 %is a Monday

     Kinna like that old horror movie ad, ain't it? 'If it don't make your 
skin crawl, it's on too tight!' ;-) 

     Figger we're dealing here with a date in the future. 

set diff=%@eval[%@date[%1]-%@date[%_date]]

     Assign numbers to the future and the current date and subtract to 
arrive at the number of days 'until'. 

set day=%@eval[%diff-(7*%@int[%@eval[%diff/7]])]

     Starting from the back end first, you divide that [%diff] number by 7, 
ignoring what's left, then mulitply by seven and subract the total from %diff. 
That leaves you with a number from 0 to 6. And, say, if today is Sunday...

:sun
set mon=1
set tue=2
set wed=3
set thu=4
set fri=5
set sat=6
return

     Make more sense?

--- msgedsq 2.1
 * Origin: - Art of the Possible - Providence (401) 421-2218 (1:323/109)

