[REBOL] txt only .r html calendar sorry :/

2000-02-28 Thread business


psss, were the html tags a bit thick last time... sorry :-\ .

; THIS version CORRECTS extra column for months whose first day lands at end
of week.
; also changes name from rebMonth.r to htmMonth.r
; Please delete the rebMonth.r it's no good.


REBOL [
   Title:  "HTML Monthly Calendar"
   Date:   19-Feb-2000
   Version: 0.0.2
   Name:   "Monthly Calendar"
   File:   %htmMonth.r
   Author: "John Braman"
   Email:  [EMAIL PROTECTED]
   Rights: { "Copyright (C) John Braman" Permission to use and improve
granted,
 with the understanding you include my footer on calendar.
  And if improvements are made please email improvements to
[EMAIL PROTECTED]
 }
   Purpose: {
   Prelude to AN INTERACTIVE HTML MONTHLY CALENDAR.
  Currently, using the Rebol Console, you enter the
  month and year you are interested in.
  This code prints the html version of that month
  to a file called rebolcal.htm "
  }

 Comment: { Thanks to  bpaddock, Olivier, Donald Dalley, Karin, rryost
especially Olivier for the slick date coding, and Donald Dalley
 and others on list who replied to my initial 'prelude to HTML post'.

Ideally future versions will be more interactive and completely
cgi-enabled with a
database or series in flat files.  However...

 I need HELP HERE:  The simplest of code that is intuitively obvious for
 veteran Rebols, is new to me.
 For example.  I've seen several html-related scripts using an "EMIT"
function,
 yet I don't know how it works.

 Ideally I'd like to retrieve values from a database or at least from a
file.
 Much like I would with coldFusion, PERL, PHP, ASP etc. However I've not
 found clear examples of dbase connection.  Or even less sophisticated
 examples of getting data from a file.  There are too few good examples of
 using REBOL words in the dictionary.  HELP !
 For example: What if I had a file with 365+ records, many of which will
contain
 the values of holidays and the like. The unique key being the date.
 How do I get data from that file via http?  How would I write to that file
for  updates?
 How do I write to that file to update the specific record only using cgi?
 }

   History: [originally called rebMonth.r version 0.0.1 created 19-2-2000
This version called htmMonth.r created 27-2-2000]
   Example: {Show how to use it.}
]
 BODY OF CODE FOLLOWS ;
; initialize

weekdays: [Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
; weeks in this calendar start with Monday, if you want them to start with
any other day then use the series or offset to the appropriate day of week.
Or change this block to start with the day of the week that you want it to.

months: [January February March April May June July August September October
November December]

; get month and year from user
userDate: PARSE ASK " Enter Month as MM , or q to exit : " NONE

IF (first userDate) = "q" [ PRINT "rebMonth.r" HALT ]
; use appropriate datatype
month:   MAKE INTEGER! FIRST userDate
year: MAKE INTEGER! SECOND userDate

; join the input and make it to be the first day of the month
inputDate: JOIN 1 [ "-" month "-" year ]
firstOfMonth: MAKE DATE! inputDate

PRINT ["Do I have it right, the month you are interested in is " PICK
months(firstOfMonth/month) year"?" NEWLINE "Cancel the write to file and re
do %htmMonth.r if it's not the right date."]


; find first of next month and first of previous month
; this will help us to find the number of days in month to make calendar
firstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 1

PRINT ["check again is this the month?" PICK months(firstOfMonth/month)]

; find days in month and days in previous month

daysInMonth: firstOfNextMonth - firstOfMonth

; firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 1
; there is a bug in the above date function which doesn't work for the first
month in the year.
; so do a work around.

Either (month = 1) [
 prevMonthName: "December"
 daysInPrevMonth: 31
 ]
 [
 firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 1
 daysInPrevMonth: firstOfMonth - firstOfPrevMonth
 ; convert previous month to words and save it.
 prevMonthName: PICK months (firstOfPrevMonth/month)
 ]; end first month bug correction

; convert the month to words, save it.
monthName: PICK months (month)
nextMonthName: PICK months (firstOfNextMonth/month)

; print the values just to check them
PRINT ["There are " daysInPrevMonth " days in " prevMonthName ] ; adjust for
first month bug
PRINT ["There are " daysInMonth " days in " monthName firstOfMonth/year ]

; is it possible to echo to a port easily for cgi purposes, what is the best
way if this were running on a server to get the following back to the
client, after evaluation of course?

ECHO  %rebolcal.htm ; write output to a file


; how do I avoid printing to the console?

; HTML header of the calendar page include title and a heading with name of
month.
print ""
print ""
print " REBOL MADE CALENDAR by John Braman's reb

[REBOL] envrion var to htm

2000-02-28 Thread business




What is the equivalent rebol expression and word (print, 
write,???) to get the cgi.r program running on the server to 
properly return HTML to the client?
 
For example, we want to return the date and time 
(nothing else) on a web page to the client what exactly would a cgi  
datetime.r file contain if it were running on linux/apache 
server?
 
Also, please provide code for another very useful 
cgi utility and tutorial.  Assume we want to show all of 
the environment variables on the html paged that is served to the 
client.   This is how I would write the script in perl.
 
#!/usr/local/bin/perl;
print "Content-type: text/html\n\n";
 
print "ENV 
Variables";
 
foreach $envirVar (keys %ENV) {
 print " $envirVar is set to $ENV{$envirVar}";
}
print "";
 
What does the environ.r cgi look like in 
Rebol?
 
AND FINALLY very low priority,
 
what if I needed to get access to the older style mail telnet 
programs.  Where currently using dos or windows... I do the 
following:
 
telnet://aztec2.asu.edu
login: username
password: letmein
q CR
mail CR
 
At this point I am asked to enter in the number of the message that I am 
interested in. followed by CR
if the message is more than one page to continue I press space bar,
for the next message it's
n CR
 
Is any one familiar with this type of mail protocol? 
.
 
 


[REBOL] .r monthly calendar improved

2000-02-28 Thread business



; THIS version CORRECTS extra column for months whose first 
day lands at end of week.; also changes name from rebMonth.r to htmMonth.r 
; Please delete the rebMonth.r it's no good.
 
REBOL [   Title:  "HTML Monthly 
Calendar"   Date:   19-Feb-2000   Version: 
0.0.2   Name:   "Monthly Calendar"   
File:   %htmMonth.r   Author: "John 
Braman"   Email:  [EMAIL PROTECTED]   
Rights: { "Copyright (C) John Braman" Permission to use and improve 
granted, 
with the understanding you include my footer on calendar. 
  And if improvements are made please email 
improvements to [EMAIL PROTECTED]. }   
Purpose: 
{  
 Prelude to AN INTERACTIVE HTML MONTHLY CALENDAR. 
  Currently, using the Rebol Console, you enter 
the  month and year you are interested in.  This 
code prints the html version of that month   to a file called 
rebolcal.htm "  }
 
 Comment: { Thanks to  bpaddock, Olivier, Donald 
Dalley, Karin, rryost    especially 
Olivier for the slick date coding, and Donald Dalley and others on list 
who replied to my initial 'prelude to HTML post'.
 
Ideally future 
versions will be more interactive and completely cgi-enabled with a 
    database or series in flat 
files.  However...
 
 I need HELP HERE:  The simplest of code that is 
intuitively obvious for  veteran Rebols, is new to me. For 
example.  I've seen several html-related scripts using an "EMIT" 
function, yet I don't know how it works.
 
 Ideally I'd like to retrieve values from a database or 
at least from a file. Much like I would with coldFusion, PERL, PHP, ASP 
etc. However I've not  found clear examples of dbase connection.  
Or even less sophisticated  examples of getting data from a file.  
There are too few good examples of using REBOL words in the 
dictionary.  HELP ! For example: What if I had a file with 365+ 
records, many of which will contain the values of holidays and the 
like. The unique key being the date. How do I get data from that file 
via http?  How would I write to that file for  updates? How 
do I write to that file to update the specific record only using cgi? 
 }
 
   History: [originally called rebMonth.r version 
0.0.1 created 19-2-2000 This version called htmMonth.r created 
27-2-2000]   Example: {Show how to use it.}] 
BODY OF CODE FOLLOWS ;; initialize
 
weekdays: [Sunday Monday Tuesday Wednesday Thursday Friday 
Saturday]; weeks in this calendar start with Monday, if you want them to 
start with any other day then use the series or offset to the appropriate day of 
week. Or change this block to start with the day of the week that you want it 
to.
 
months: [January February March April May June July August 
September October November December]
 
; get month and year from useruserDate: PARSE ASK " Enter 
Month as MM , or q to exit : " NONE
 
IF (first userDate) = "q" [ PRINT "rebMonth.r" HALT ]; use 
appropriate datatypemonth:   MAKE INTEGER! FIRST userDateyear: 
MAKE INTEGER! SECOND userDate
 
; join the input and make it to be the first day of the 
monthinputDate: JOIN 1 [ "-" month "-" year ]firstOfMonth: MAKE DATE! 
inputDate
 
PRINT ["Do I have it right, the month you are interested in is 
" PICK months(firstOfMonth/month) year"?" NEWLINE "Cancel the write to file and 
re do %htmMonth.r if it's not the right date."]
 
; find first of next month and first of previous 
month; this will help us to find the number of days in month to make 
calendarfirstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 
1
 
PRINT ["check again is this the month?" PICK 
months(firstOfMonth/month)]
 
; find days in month and days in previous month
 
daysInMonth: firstOfNextMonth - firstOfMonth
 
; firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 
1; there is a bug in the above date function which doesn't work for the 
first month in the year. ; so do a work around.
 
Either (month = 1) [ prevMonthName: 
"December" daysInPrevMonth: 31 ] 
 [ firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 
1 daysInPrevMonth: firstOfMonth - firstOfPrevMonth ; convert 
previous month to words and save it. prevMonthName: PICK months 
(firstOfPrevMonth/month) ]; end first month bug correction
 
; convert the month to words, save it.monthName: PICK 
months (month)nextMonthName: PICK months 
(firstOfNextMonth/month)
 
; print the values just to check themPRINT ["There are " 
daysInPrevMonth " days in " prevMonthName ] ; adjust for first month 
bugPRINT ["There are " daysInMonth " days in " monthName firstOfMonth/year 
]
 
; is it possible to echo to a port easily for cgi purposes, 
what is the best way if this were running on a server to get the following back 
to the client, after evaluation of course?
 
ECHO  %rebolcal.htm ; write output to a file
 
; how do I avoid printing to the console?
 
; HTML header of the calendar page include title and a heading 
with name of month.print ""print ""print 
" REBOL MADE CALENDAR by John Braman's rebMonth.r 
"print ""print ""p

[REBOL] CGI interpreter on win95 apache Re:

2000-02-23 Thread business

Your post was fascinating because when I used clicked to open it with my MS
Outlook express it pops open a blank ie window about 500x600 with no
controls and the following error message... Internet Explorer cannot open up
the file C//:\web\iejit.htm

How did you do that?

braman




- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 23, 2000 7:40 PM
Subject: [REBOL] CGI interpreter on win95 apache


>
>  How can I make rebol a cgi interpreter on win95 apache ?
>
>  I can easily make perl work.  Just copy the perl script to cgi-bin
and
>  make sure a #!C:/PERL/BIN/PERL at the top.  I don't even need to
touch
>  the apache .conf files.
>
>  I did the same to rebol.  First it popup a rebol window and show all
>  my stuff there instead of the browser.  Searched rebol.org and got
the
>  -c or -cgi solution.  It did suppress the rebol window but nothing
>  went to the browser.
>
>  I guess apache captures stdout and sends to the browser.  rebol does
>  not print to stdout and that's the problem.



[REBOL] .r to html monthly calendar prelude Re:(2)

2000-02-23 Thread business


>Here is something more efficient :
>
>>> firstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 1
>== 1-Mar-2000
>>> daysInMonth: firstOfNextMonth - firstOfMonth
>== 29
>
>
>print [" There are " daysInMonth " days in " currentMonth now/year]
>
>Olivier

Thanks for the elegant code above... run the following... an oddity
occurs...

REBOL [
   Title:  "What's the proper way to do the date function to avoid first
month of year - last month of previous year oddity?"
   Date:   19-Feb-2000
   Version: 0.0.1
   Author: "John Braman"
   Email:  [EMAIL PROTECTED]
]

weekdays: [Monday Tuesday Wednesday Thursday Friday Saturday Sunday]
; weeks in this calendar start with Monday, if you want them to start with
any other day then use the series or offset to the appropriate day of week.
Or change this block to start with the day of the week that you want it to.

months: [January February March April May June July August September October
November December]

; get month and year from user
PRINT "To expose bug type 1st month of any year, like 1 2000, or 1 1999,
etc."
userDate: PARSE ASK " Enter Month as MM , or q to exit : " NONE

IF (first userDate) = "q" [ PRINT "HTMLCalendar.r" HALT ]
; use appropriate datatype
month:   MAKE INTEGER! FIRST userDate
year: MAKE INTEGER! SECOND userDate

; join the input and make it to be the first day of the month

inputDate: JOIN 1 [ "-" month "-" year ]
firstOfMonth: MAKE DATE! inputDate

PRINT ["So you are intrested in is "  PICK months (firstOfMonth/month) year]

; find first of next month and first of previous month
; this will help us to find the number of days in month to make calendar and
should automatically account for leap years.
; note this works for all months except the first month of any year.

firstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 1
firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 1

; find days in month and days in previous month
daysInMonth: firstOfNextMonth - firstOfMonth
daysInPrevMonth: firstOfMonth - firstOfPrevMonth

; convert the month to words, save it.
monthName: PICK months (month)
prevMonthName: PICK months (firstOfPrevMonth/month) ; use date value incase
month-1=0
nextMonthName: PICK months (firstOfNextMonth/month)

; print the values just to check them
PRINT ["There are " daysInPrevMonth " days in the previous month of "
prevMonthName  firstOfPrevMonth/year]
PRINT ["There are " daysInMonth " days in " monthName firstOfMonth/year ]



[REBOL] doleman html Calendar follow up.

2000-02-23 Thread business



>Here is something more efficient 
: firstOfNextMonth: firstOfMonth/month: 
firstOfMonth/month + 1>== 1-Mar-2000>>> daysInMonth: 
firstOfNextMonth - firstOfMonth>== 29>>>print [" 
There are " daysInMonth " days in " currentMonth 
now/year]>>Olivier
Thanks for the elegant code above... run the 
following... an oddity occurs...
 
REBOL [   Title:  "What's the proper way to 
do the date function to avoid first month of year - last month of 
previous year oddity?"   Date:   
19-Feb-2000   Version: 0.0.1   Author: "John 
Braman"   Email:  [EMAIL PROTECTED]
]
 
weekdays: [Monday Tuesday Wednesday Thursday Friday Saturday 
Sunday]; weeks in this calendar start with Monday, if you want them to start 
with any other day then use the series or offset to the appropriate day of week. 
Or change this block to start with the day of the week that you want it 
to.
 
months: [January February March April May June July August 
September October November December]
 
; get month and year from user
PRINT "To expose bug type 1st month of any year, like 1 
2000, or 1 1999, etc."userDate: PARSE ASK " Enter Month as MM , or q to 
exit : " NONE
 
IF (first userDate) = "q" [ PRINT "HTMLCalendar.r" HALT ]; 
use appropriate datatypemonth:   MAKE INTEGER! FIRST 
userDateyear: MAKE INTEGER! SECOND userDate
 
; join the input and make it to be the first day of the 
month
 
inputDate: JOIN 1 [ "-" month "-" year ]firstOfMonth: MAKE 
DATE! inputDate
 
PRINT ["So you are intrested in is "  PICK months 
(firstOfMonth/month) year]
 
; find first of next month and first of previous month; 
this will help us to find the number of days in month to make calendar and 
should automatically account for leap years.
; note this works for all months except the first month of any 
year.
firstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 
1firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 1
 
; find days in month and days in previous 
monthdaysInMonth: firstOfNextMonth - firstOfMonthdaysInPrevMonth: 
firstOfMonth - firstOfPrevMonth
 
; convert the month to words, save it.monthName: PICK 
months (month)prevMonthName: PICK months (firstOfPrevMonth/month) ; use date 
value incase month-1=0nextMonthName: PICK months 
(firstOfNextMonth/month)
 
; print the values just to check themPRINT ["There are " 
daysInPrevMonth " days in the previous month of  " prevMonthName  
firstOfPrevMonth/year]PRINT ["There are " daysInMonth " days in " monthName 
firstOfMonth/year ]


[REBOL] WOW a rebol HTML calendar, please do % and criticize

2000-02-21 Thread business



; please run this and comment as you will :-)
 
 
REBOL [   Title:  "HTML Monthly 
Calendar"   Date:   19-Feb-2000   Version: 
0.0.1   Name:   "Monthly Calendar"   
File:   %rebMonth.r   Author: "John 
Braman"   Email:  [EMAIL PROTECTED]   Rights: { 
"Copyright (C) John Braman" Permission to use and improve 
granted, 
with the understanding you include my footer on calendar. 
  And if improvements are made please email 
improvements to [EMAIL PROTECTED]. }   
Purpose: 
{  
 Prelude to AN INTERACTIVE HTML MONTHLY CALENDAR. 
  Currently, using the Rebol Console, you enter 
the  month and year you are interested in.  This 
code prints the html version of that month   to a file called 
rebolcal.htm "  }
 
   Comment: { Thanks to  bpaddock, olivier 
doleman, Donald Dalley, karin, 
rryost    especially Olivier doleman 
for the slick date coding, and Donald Dalley and others on list who 
replied to my initial 'prelude to HTML post'.
 
    The next version 
will be more interactive and completely cgi-enabled with a 
    database or series in flat 
files.  However...
 
 I need HELP HERE:  The simplist of code that is 
intuitively obvious for  veteran Rebols, is new to me. For 
example.  I've seen several html related scripts using an "EMIT" 
function, yet I don't know how it works.
 
 The ideal is to retrieve values from a database or at 
least from a file, much like one using coldFusion, PERL, PHP, ASP etc. 
However I've not  found clear examples of dbase connection.  Or 
even less sophisticated  examples of getting data from a flat 
file.  There are too few good examples of using REBOL words in the 
dictionary.  HELP ! For example: What if I had a file with 365+ 
records many of which will conatin the values of holidays and the like. 
The unique key being the date. How do I get data from that file via 
http?  How would I write to that file for updates? How do I write 
to that file to update the specific record only using cgi? 
 }
 
   History: [version 0.0.1 created 
19-2-2000]   Example: {Show how to use it.}] 
BODY OF CODE FOLLOWS ;
 
; initialize
 
weekdays: [Monday Tuesday Wednesday Thursday Friday Saturday 
Sunday]; weeks in this calandar start with Monday, if you want them to start 
with any other day then use the series or offset to the appropriate day of week. 
Or change this block to start with the day of the week that you want it 
to.
 
months: [January February March April May June July August 
September October November December]
 
; get month and year from useruserDate: PARSE ASK " Enter 
Month as MM , or q to exit : " NONE
 
IF (first userDate) = "q" [ PRINT "HTMLCalendar.r" HALT ]; 
use appropriate datatypemonth:   MAKE INTEGER! FIRST 
userDateyear: MAKE INTEGER! SECOND userDate
 
; join the input and make it to be the first day of the 
monthinputDate: JOIN 1 [ "-" month "-" year ]firstOfMonth: MAKE DATE! 
inputDate
 
PRINT ["Do I have it right, the month you are intrested in is 
" PICK months(firstOfMonth/month) year"?"]
 
; find first of next month and first of previous month; 
this will help us to find the number of days in month to make 
calendarfirstOfNextMonth: firstOfMonth/month: firstOfMonth/month + 
1
 
PRINT ["check again is this the month?" PICK 
months(firstOfMonth/month)]
 
; find days in month and days in previous month
 
daysInMonth: firstOfNextMonth - firstOfMonth
 
; firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 
1; there is a bug in the above date function which doesn't work for the 
first month in the year. ; so do a work around.
 
Either (month = 1) [ prevMonthName: 
"December" daysInPrevMonth: 31 ] 
 [ firstOfPrevMonth: firstOfMonth/month: firstOfMonth/month - 
1 daysInPrevMonth: firstOfMonth - firstOfPrevMonth ; convert 
previos month to words and save it. prevMonthName: PICK months 
(firstOfPrevMonth/month) ]; end first month bug correction
 
; convert the month to words, save it.monthName: PICK 
months (month)nextMonthName: PICK months 
(firstOfNextMonth/month)
 
; print the values just to check themPRINT ["There are " 
daysInPrevMonth " days in " prevMonthName ] ; adjust for first month 
bugPRINT ["There are " daysInMonth " days in " monthName firstOfMonth/year 
]
 
; is it possible to echo to a port easily for cgi purposes, 
what is the best way if this were running on a server to get the follwing back 
to the client, after evaluation of course?
 
ECHO  %rebolcal.htm ; write output to a file
 
; how do I surpress the printing to the 
console?
 
; HTML header of the calendar page include title and a heading 
with name of month.print ""print ""print 
" REBOL MADE CALENDAR by John Braman's rebolcal.htm 
"print ""print ""print 
""print 
[monthName firstOfMonth/year] ; we get month from the inputprint 
""
 
; Print table, heading days of week, start with 
Mondayprint ""i: 1while [i <= 7] 
[ print ["" 
PICK weekdays(i) ""] i: i + 1] ; 
end while for headingsprint ""
 
; Put the data into the tabl

[REBOL] bpaddocks revival of Zeller's congruence Re:

2000-02-19 Thread business

; Here's a working zeller.r script...
; corrected a few of the goofs from previous post.

; note that this isn't quite what I was looking for when I posted the
calendar.r html making letter
; however it's nice to know about  Zeller's Congruence...


REBOL [
Title:  "bpaddock revival of Zeller's Convergenc or print the day of the
Week"
Date:   18-Feb--2000
Author: "converted from c? by JB c source provided by bpaddock"
Version: 1.0.0
Purpose: "Shows day of the week, because we can"
]


;>
;> The 'standard', if there is such a thing, for figuring out
;> the day of the week is "Zeller's Congruence".  His formula
;> might help you out.
;>
;> Sorry that I didn't take the time to convert it to Rebol.
;> Would like to see it that way if some one is so inclined.
;>
; jb was inclined as long as bpaddock edits...and error corrects
;> /* Zeller's Congruence: From "Acta Mathematica #7, Stockholm, 1887.
;>
;> Determine the day of the week give the year, month, and the
;> day of the month; which are passed in the structure 'utc'
;>
;> return(  0 = Sunday...6=Saturday ) and also set utc->wday
;>
;> J = Century (ie 19), K = Year (ie 91), q = Day of the month, m = Month
;>
;> March = month #3December = month #12,
;> January = month #13, February = month #14 OF THE PREVIOUS YEAR.
;>
;> [q + [((m + 1) * 26 ) / 10] + K + (K / 4) + (J / 4) - (2 * J)] % 7
;>  Because of the "% 7" term, -(2*J), and +(5*J) give the same answer.
;>
;> */
;> ;

Print "If you want to know what day of the week any date is?"
Print " Please, enter the year give all four digits "
oyear: input
year: make integer! oyear


; I DON'T know what the equivalent commands in Rebol are for initializing?
;> UINT weekday( gmt )
;> struct utc *gmt;
;> {
;>  UINT  mth, year, cent;
;>  register UINT temp;
;>  year = gmt->year;
;>  mth  = gmt->month;
;>

Print "Enter the month as m or mm"

omth: input
mth: make integer! omth ; how is this supposed to be set to integer?
if mth < 3


mth: mth + 12
year: year - 1
] ;end if
; what is the proper way to enter more than one statement?
; could I have written:
; if mth < 3 [mth: mth + 12 year: year - 1]
;>  if( mth < 3 )
;>  {
;>   mth += 12;
;>   --year;
;>  }
;>

cent:  year / 100
;>  cent = year / 100; /* 19th, 20th, or 21th etc century */

; ok bpaddock what's the % command do here?  remainder? Modulo? Integer
Modulo?
; Just what is this dulo that I'm asking more of ? (imagine that being said
by Groucho Marx?)
; even though I know it's not modulus does rebol have a modulus operator?

;>  year %= 100; /* Tens of years (00->99) */

year:  remainder year 100


Print "Enter the day of the month as either d or dd"

dd: input
dd: make integer! dd

; or the above could be extraced from the present day as in the line below:
; dd: now/day ; but I prefer the interactive effect... the present is so
limiting

;>  temp  = gmt->day; /* Start with the day of the month */
; we have day of the month from input
;>  temp += (((mth + 1) * 26) / 10); /* Advance to the start of the month */
temp: dd + (((mth + 1) * 26) / 10) ; gosh I hope that syntax works in
Rebol...

;>
;>  temp += year; /* [K]   Add in the year */
temp: temp + year

;>
;>  temp += (year / 4); /* [K/4] Correct for leap years */
temp: temp + year / 4
;  I haven't reviewed the hierarchy of operators but above line should
work...
;>
;> /* Because of the "% 7" term, -(2*J), and +(5*J) give the same answer: */
;>  temp += (cent * 5); /* [J*5]  Correct for centuries  */
temp: temp + (cent * 5)
;>
;>  temp += (cent / 4); /* [J/4] Give extra day ever 400 years */
temp: temp + (cent / 4)
;>
;>  temp %= 7; /* 7 days in a week */

print ["temp before dividing by 7 = " temp]

temp:  remainder temp 7

print ["temp after dividing by 7 = " temp]

temp: make integer! temp

print ["temp after temp: make integer! temp = " temp]

;>
;>  if( !temp ) /* Wrap Saturday to be the last day of week */
if temp = 0 [ temp = 7]
;>   temp = 7;
;>
;>  temp -= 1; /* 0 = Sunday...6=Saturday */
; in my case I want 1 = Sunday  7 = Saturday...


print [" The day of the week you were looking for "dd"/"omth"/"oyear " is "
   switch temp [
1 ["Sunday"]
2 ["Monday"]
3 ["Tuesday"]
4 ["Wednesday"]
5 ["Thursday"]
6 ["Friday"]
7 ["Saturday"]
   ]; ends switch
]; ends print


; >
; >  gmt->wday = temp;
; >
; >  return( temp );
; > }



[REBOL] bpaddocks revival of Zeller's congruence

2000-02-19 Thread business

;wow... neat formula... I'm inclined to convert... I've already begun below
amidst the body of your message...
;I set out a few months ago to figure this out... and was easily sidetracked
;-)
;before I go on I just say that your mail showed up with an unusual Icon in
my MS Outlook express inbox...
;it was a little notepad with a pen or pencil... where as most of the other
mail shows up as an envelope...
;please enlighten me... I know it's got something to do with newsgroups...
but what?? ah isn't it sweet to be so
;young and naive...

; however I was hoping for a simpler way to just convert the day or month
into words
; and find any other calendar functions rather than using the switch
method...

;I've tossed in a few odd comments below but I think I get the jist of it...
; also you'll note that when you run this... it' will come back with an
error about integers
; cause I don't know how initialize these properly... any suggestions are
welcome
;thanks...

;jb


REBOL [
Title:  "bpaddock revival of Zeller's Convergenc or print the day of the
Week"
Date:   18-Feb--2000
Author: "converted from c? by JB c source provided by bpaddock"
Version: 1.0.0
Purpose: "Shows day of the week, because we can"
]


;>
;> The 'standard', if there is such a thing, for figuring out
;> the day of the week is "Zeller's Congruence".  His formula
;> might help you out.
;>
;> Sorry that I didn't take the time to convert it to Rebol.
;> Would like to see it that way if some one is so inclined.
;>
; jb was inclined as long as bpaddock edits...and error corrects
;> /* Zeller's Congruence: From "Acta Mathematica #7, Stockholm, 1887.
;>
;> Determine the day of the week give the year, month, and the
;> day of the month; which are passed in the structure 'utc'
;>
;> return(  0 = Sunday...6=Saturday ) and also set utc->wday
;>
;> J = Century (ie 19), K = Year (ie 91), q = Day of the month, m = Month
;>
;> March = month #3December = month #12,
;> January = month #13, February = month #14 OF THE PREVIOUS YEAR.
;>
;> [q + [((m + 1) * 26 ) / 10] + K + (K / 4) + (J / 4) - (2 * J)] % 7
;>  Because of the "% 7" term, -(2*J), and +(5*J) give the same answer.
;>
;> */
;> ;

Print "If you want to know what day of the week any date is?"
Print " Please, enter the year give all four digits "
year: integer! year
year: input


; I DON'T know what the equivalent commands in Rebol are for initializing?
;> UINT weekday( gmt )
;> struct utc *gmt;
;> {
;>  UINT  mth, year, cent;
;>  register UINT temp;
;>  year = gmt->year;
;>  mth  = gmt->month;
;>

Print "Enter the month as m or mm"
mth: integer! mth ; how is this supposed to be set to integer?

mth: input

if mth < 3


mth: mth + 12
year: year - 1
] ;end if
; what is the proper way to enter more than one statement?
; could I have written:
; if mth < 3 [mth: mth + 12 year: year - 1]
;>  if( mth < 3 )
;>  {
;>   mth += 12;
;>   --year;
;>  }
;>

cent:  year / 100
;>  cent = year / 100; /* 19th, 20th, or 21th etc century */

; ok bpaddock what's the % command do here?  remainder? Modulo? Integer
Modulo?
; Just what is this dulo that I'm asking more of ? (imagine that being said
by Groucho Marx?)
; even though I know it's not modulus does rebol have a modulus operator?

;>  year %= 100; /* Tens of years (00->99) */

year:  remainder year 100


Print "Enter the day of the month as either d or dd"
dd: integer! dd


dd: input

; or the above could be extraced from the present day as in the line below:
; dd: now/day ; but I prefer the interactive effect... the present is so
limiting

;>  temp  = gmt->day; /* Start with the day of the month */
; we have day of the month from input
;>  temp += (((mth + 1) * 26) / 10); /* Advance to the start of the month */
temp: dd + (((mth + 1) * 26) / 10)  gosh I hope that syntax works in
Rebol...

;>
;>  temp += year; /* [K]   Add in the year */
temp: temp + year

;>
;>  temp += (year / 4); /* [K/4] Correct for leap years */
temp: temp + year / 4
;  I haven't reviewed the hierarchy of operators but above line should
work...
;>
;> /* Because of the "% 7" term, -(2*J), and +(5*J) give the same answer: */
;>  temp += (cent * 5); /* [J*5]  Correct for centuries  */
temp: temp + (cent * 5)
;>
;>  temp += (cent / 4); /* [J/4] Give extra day ever 400 years */
temp: temp + (cent / 4)
;>
;>  temp %= 7; /* 7 days in a week */
temp:  remainder temp 7

;>
;>  if( !temp ) /* Wrap Saturday to be the last day of week */
if temp = 0 [ temp = 7]
;>   temp = 7;
;>
;>  temp -= 1; /* 0 = Sunday...6=Saturday */
; in my case I want 1 = Sunday  7 = Saturday...
print [" The day of the week you were looking for " month year " is "
   switch temp [
1 ["Sunday"]
2 ["Monday"]
3 ["Tuesday"]
4 ["Wednesday"]
5 ["Thursday"]
6 ["Friday"]
7 ["Saturday"]
   ]; ends switch
]; ends print




; >
; >  gmt->wday = temp;
; >
; >  return( temp );
; > }



[REBOL] .r to html monthly calendar prelude

2000-02-19 Thread business



Do any rebols have examples of .r scripts that create monthly 
calendars thatthey are willing to share?  Or even a few thoughts on how 
you would create one.
 
The following are some simple scripts I made yesterday as a 
prelude to html monthly calendar.  The work, however I'd love to see how 
other people are thinking about calendar.r that will create interactive 
monthly calendars for events, etc  Ideally some link to a database or 
(block?) or (series?) will be useful so that http:// visitors or administrator will be able to 
change the events visa the http:// link.  
 
But before you see the prelude to the calendar scripts, let's 
assume I want to provide access to an http://wateva.com/admincal.r how do I go 
about protecting that admincal.r file so only the persons with the 
proper username and password have access?  I'm talking about the internet 
here not a private intranet...  ideally the admincal.r will ask the person 
for a username and password.  If not correct it will send them to some 
index.htm or index.r file after a few tries.  If they are authorized 
via the proper username and password that they enter then it continues on with 
the rest if the script allowing them to update or delete events, 
etcetera.
 
REBOL [    Title:  "day of the 
Week"    Date:   18-Feb--2000    
Author: "J B"    Version: 1.0.0    
Purpose: "Shows day of the week and number of days in months, it's a prelude to 
an HTML monthly calendar"]
 
print "The ify way to show today is "  if now/weekday 
= 1 [print "Monday"]  if now/weekday = 2 [print "Tuesday"]  if 
now/weekday = 3 [print "Wednesday"]  if now/weekday = 4 [print 
"Thursday"]  if now/weekday = 5 [print "Friday"]  if 
now/weekday = 6 [print "Saturday"]  if now/Weekday = 7 [print 
"Sunday"]
 
print [" The switch way to show today is "   
switch now/weekday [  1 ["Monday"] 2 ["Tuesday"] 3 
["Wednesday"] 4 ["Thursday"] 5 ["Friday"] 6 
["Saturday"] 7 ["Sunday"]   ]; ends switch]; ends 
print
 
; QUESTION there's go to be more elegant ways of getting the 
named day than this?print [newline "QUESTION there's go to be more elegant 
ways of getting the named day than the two ways I've shown here?" 
newline]
 
; convert the current month to words, save it.switch 
now/month [ 1 [currentMonth: "January"] 2 [currentMonth: 
"February"] 3 [currentMonth: "March"] 4 [currentMonth: 
"April"] 5 [currentMonth: "Mayo"] 6 [currentMonth: 
"June"] 7 [currentMonth: "Julio"] 8 [currentMonth: 
"Augusta"] 9 [currentMonth: "September"] 10 [currentMonth: 
"Octopus"] 11 [currentMonth: "Novice"] 12 [currentMonth: 
"Decent"]    ] ; end switch of 
month
 
firstOfMonth: now - now/day + 1
 
Print ["the first day of " currentMonth now/year 
"was"   switch firstOfMonth/weekday [ 1 
["Monday"] 2 ["Tuesday"] 3 ["Wednesday"] 4 
["Thursday"]  5 ["Friday"]  6 
["Saturday"] 7 ["Sunday"]   ] ; ends the switch] ; 
ends first day of month print
 
 
 
;figure out the number of days in this month and 
print
 
monthInQeustion: now/monthEOMtest: firstOfMonth + 
27
 
print ["before using to-date is EOMtest a date? " date? 
EOMtest]EOMtest: to-date EOMtestprint ["after to-date is EOMtest a date? 
" date? EOMtest]; I'd like to assign the above to EOMtest: [firstOfMonth + 
27] ; however then if I use EOMtest/month it claims 'invalid path value: 
month'; I had to-date the EOMtest Now after working on this all day long I'm 
not sure ; about this so the following question maybe a bit 
silly...;; QUESTION why doesn't the type date value automatically 
transfer to the new variable?;; Note: the second time you run this both 
of the date? of EOMtest will be true,; because EOMtest is now in a date type 
resulting from ; the previous run unless of course you've reset all the 
variables;-}; which brings me to my next 
 
; QUESTIION how do I easily clear or reset variables at the 
begining of the script?
 
month: monthInQuestionwhile [month = monthInQuestion] 
[  EOMtest: EOMtest + 1   daysInMonth: EOMtest/day  
month: EOMtest/month ] ; ends code of while block; go back one day 
for last day in monthEOMtest: EOMtest - 1daysInMonth: 
EOMtest/dayprint [" There are " daysInMonth " days in " currentMonth 
now/year] 
 
; figuring out how many days in month; one way that 
seems intutive if I could do somthing like ; goToEndOfMonth: make date! [dd 
mm yy] where dd mm and yy are actually variables; and iterate using any of 
dd mm or yy... but that doesn't seem to work; help on the above... line is 
appreciated; than I could itereate any of these values.; and test for 
when mm change the previous dd is the number of days in month; instead I do 
the following... ; however, tmtowtdi so ... more elegant solutions will be 
greatly appreciated.
 
print "Enter a date in the following format  dd-mm-yy 
I'll tell you the day of the week of the first day, the last day and the number 
of days in that month."print " go ahead dd-mm-yy "
 
inputDate: inputinputDate: to-date 
inputDatedateInQuestion: inputDatemonthInQuestion: 
dateInQuestion