Program files : weekday (zip file containing weekday.PRC)
The backstory for the program :
Intro : The Data Structures class here at LTU has a
project to turn John Conway's
Doomsday algorithm into C code. One of the students (Steve M.)
mentioned the project, and that reminded me that I had a neat calendar
book that had different algorithms for finding the day of the week. Lewis
Carroll (of "Alice in Wonderland" fame) has a method also
[Actually, John Conway's method is a better explanation of the theory than
Lewis Carroll - Carroll has things like "if the month begins or ends
with a vowel"!]. So, flush with success at creating a small "Hello"
program for the PalmOS, I decided to encode that algorithm (Conway's) and
then will add others later. At the same time, Josh T. pointed out the
OnBoard C compiler that you can get for the palm. It's a slick little
piece of programming, that let's you write code directly on the palm.
Initial coding : I got the skeleton of the program
together (by using an example program that comes with OnBoard C), but then
needed a way to get the "date requested" into the program. Well,
Palm has this very handy "calender popup" called SelDay .. why
not use that? Well, as I cobbled together the code to run that ... FATAL
EXCEPTION. Doh! Josh T. comes
to the rescue and figures out how to add the SelDay routine to the
standard header file in OnBoard .. success! [Now, it might seem silly to
use the calendar function ... which shows the day of the week for
the day you picked anyway ... as the input device. My defense is
.. it is easy to get an accurate date in that way ... and the point of the
program is to show that there is an algorithm that will consistantly
figure out the day of the week, given only the day, month, year
information. So, leave me alone about that!
Case problems : I struggled with the code just a bit
(the standard C code that I got from some helpful students {Mark W.,
Orlando W., and Wesley S.} seems to allow "real" numbers to go
into a case statement (which normally expects integers). But the Palm
didn't ... so I finally worked around that. [Let me point out that I have
this implimented in DELPHI ... I am just unfamiliar with C, so it helped
to have the C code to follow!]
Oops! : As I proudly showed off my program to my
Theoretical Mechanics class .. Dave C joyfully pointed out that it wasn't
working with the year 1999 or earlier! Doh! Doh!
Those darn Case statements again ... worked around that and got it to
finally act properly. (It sort of helps that the Palm only deals with 1904
- 2031.)
Success : Finally I worked out all the little bugs
and got the day of the week to print out on the screen. [The Palm is not
very helpful when it comes to print text on the screen ... lock this ..
unlock this ... turn your head, cough .. copy string here ..] It now shows
the Conway code, the Carroll code, and PalmOS's own dayofweek function -
whew!
Source Code? : Since this is a project that is
assigned to the students here .. I don't want to release the source code.
I will for other projects!
Screen Shots : Here are some screen shots of the program in operation.