[comp.sys.handhelds] YACPP

akcs.kevin@hpcvbbs.UUCP (Kevin Jessup) (04/25/91)

Since various revisions (minus the documentation) of my CALENDAR
program are floating around the network again, I thought I'd post
the "official" version one more time.  This includes the documenta-
tion file, RPL listings and the "ASC encoded" directory.  Again, let
me apologize for the bug in the ALMDATE? routine of the original
posting.  I make no claims as to this calendar program being better
than anyone else's.  Try them all and decide for yourself.

*********************************************************************
*      DOCUMENTATION FILE FOR HP48SX CALENDAR DRAWING FUNCTIONS     *
*                          Version 1.02                             *
*                                                                   *
*               by Kevin Jessup  October 23rd, 1990                 *
*                  3rd net posting on 24-Apr-1991                   *
*********************************************************************

A thousand appologies.  I screwed up again!  There was still a bug in
the ALMDATE? routine that I said was fixed in version 1.01.  So much
for my software validation methods.  Let's try one more time!  Here
is version 1.02.  The ALMDATE? routine is the only difference between
this and previous versions.

If you have successfully loaded the binary CALENDAR directory file, a
directory named CALENDAR should now be in your current working
directory.  Place 'CALENDAR' on the stack, go to the MEMORY menu and
press BYTES.  Verify the following...

   Checksum:     # 14BA (hex) or # 5306 (decimal) on stack level 2
   Byte count:   2479 on stack level 1

Note: The checksum will change if the day, month or year global variables
have been modified since you downloaded the directory.

Introduction
------------
These routines will display a calendar graphic for a specific year and
month on the 48SX display.  Functions are provided to move the calendar
forward or backwards in month or year increments.  Day of week and leap
year functions are also provided.

The CALENDAR directory should contain the following objects in the order
they appear below.  For ease of use, DO NOT re-order the directory.
Objects preceeded by an asterisk (*) are described in detail later.  All
other objects are subroutines used by the main functions and are NOT
described.  A listing of ALL objects is provided at the end of the
documentation.

Name       Object type     Purpose
-------    -----------     --------------------------------------------
* CURR     program         Draws a calendar for the current month.
* <-Y      program         Draws a calendar for the previous year,
                           same month.
* Y->      program         Draws a calendar for the next year, same
month.
* <-M      program         Draws a calendar for the previous month,
                           same year.
* M->      program         Draws a calendar for the next month, same
year.
* PCAL     program         Prints the last calendar dislayed.
* CAL      program         Given specific month and year,
                           draws the calendar.
* DOW      program         Returns current day of week string to stack.
* SDOW     program         Given a date, returns day of week string
                           to stack.
* RDOW     program         Given a date, returns day of week number
                           to stack.
* LPYR     program         Given a year, determines if it is a leap year.
* ALMDATE? program         Given a date, determines if any alarms are
due.
  MOY      list            Months of the year.
  DIM      list            Number of days in the months.
  DOWL     list            Days of the week.
  GENC     program         Main calendar graphic generating function.
  FILLD    program         Adds days and alarm flags to the calendar
                           graphic.
  MONTHBOX program         Draws the calendar graphic lines and days of
                           week.
  CPSDT    program         Compress date and time.
  EXPDT    program         Expand date and time.
  JFIX     program         Adjust for date mode.
  day      real number
  year     real number
  month    real number
  PPAR     list            Plot parameters.

Detailed function descriptions
------------------------------

CURR   Draws a calendar for the current month.  A graphic display of
       the month, year and appropriately positioned day numbers is
       generated.  Days that have an alarm associated with them will
       contain a box to mark the alarm.

<-Y    Same as CURR but backs up one year.

Y->    Same as CURR but moves forward one year.

<-M    Same as CURR but backs up one month.

M->    Same as CURR but moves forward one month.

PCAL   Prints the current contents of the PICT variable.  If some other
       program has not deleted PICT or modified it, the object printed
       should be the last calendar you displayed.

CAL    Given a date on the stack in valid HP48SX date format (MM.DDYYYY
       or DD.MMYYYY) displays the calendar for the month as in CURR.

DOW    Returns the current day of week text string to the stack.

SDOW   Given a date as in CAL, returns the day of week text string to
       the stack.

RDOW   Same as SDOW but returns a real number.
       Sunday = 0, Monday = 1,  ...  Saturday = 6.

LPYR   Given a year on level 1, returns 1 if it is a leap year, else 0.

ALMDATE?
       Given a date as in CAL, returns 1 if alarms are due on that date,
       else 0.  Always returns 0 if date input is less than the current
       date (Does not detect past-due alarms!).

Warranties and Support
----------------------
None provided.  Programs are supplied AS IS.  If it blows up, you better
have an archive handy.

Freeware
---------
Hope you find it of use.  Please do not modify without giving me a little
credit for the original.

Suggested enhancements
----------------------
Have the ARROW keys of the 48SX move a reverse video box that highlites
the day of interest.  Pushing enter brings up a menu for adding a new
alarm for the highlited day and/or editing existing alarms due on that
day.  As the cursor moves beyond the current month, the new month is
drawn.

                                                   Kevin Jessup
                                                   9118 N. 85th St.
                                                   Milwaukee, WI 53224

Here is the ASC encoded directory
---------------------------------
[CUT HERE]
%%HP: T(1)A(R)F(.);
"69A20FF7B03100000040050514254047A2077920000000000000056900000000
000001397792000000000000005600000000000000230C1BA44B2A2A2BA4166E
195BA4B21309700050D6F6E64786503392010000000000000103200040975616
2740339203000000000009910120003046169730339201000000000000320F10
0040A464948540D9D20E16323CE22339201000000000000249063C1AFE22D9D2
03F2A20DCF1DBBF13F2A25BCF1B21305DF2293632B2130C60005054850544455
0D9D20E163278BF1D6BB1DBBF13ABB1339202000000000000010EEDA178BF1D6
BB1DBBF13ABB1339204000000000000010EEDA193632B2130E70005034053544
4550D9D20E163233920400000000000001050FA1DBBF1D6BB176BA1339202000
00000000001050FA1DBBF1D6BB176BA193632B21304700080D4F4E4458424F48
580D9D20E1632E4A20510003800000000000000E4A2051000E30000000000000
0614E1634E1DCC0247A20E4A20510002000000000000000E4A20510000000000
000000000B213047A20E4A20510000800000000000000E4A2051000000000000
0000000B2130893E147A20E4A20510002000000000000000E4A2051000000000
0000000000B213047A20E4A20510002000000000000000E4A2051000D3000000
00000000B2130893E147A20E4A20510000800000000000000E4A205100000000
00000000000B213047A20E4A20510000800000000000000E4A2051000D300000
000000000B2130893E1E4A2051000E0000000000000009C2A2743A230132E4A2
051000200000000000000092CF1ED2A2387C192CF1E4A2051000080000000000
0000DBBF1ED2A2387C1893E1E4A2051000800000000000000076BA1C42328DBF
1E4A205100041000000000000009C2A2233A23013278BF1E4A2051000F000000
000000000ED2A2387C192CF1E4A2051000E300000000000000ED2A2387C1893E
1E4A2051000210000000000000076BA1C42328DBF1E4A2051000500000000000
00009C2A2743A20A132D6E20109678BF1E4A20510008000000000000000ED2A2
387C184E204044F475C4D6E2010966C7D19C2A23F2A2C58C19C2A2DA5E1634E1
3F2A20DCF1AE8C1E4A2051000210000000000000076BA1C42328DBF193632B21
3031400806494C4C44414953580D9D20E16329C2A284E2050D6F6E6478684E20
409756162784E2040A464948584E2050340535444584E20402544F4754B2A29C
2A284E20304494D484E2050D6F6E647866C7D13CE2284E2050D6F6E64786ED2A
2279E184E20409756162784E2040C4059525387E1AFE22D9D209C2A276BA1B21
305DF220A132D6E201046634E13F2A2A9CF1B9691E4A20510002100000000000
000EEDA1E4A2051000600000000000000076BA13F2A2A9CF1B9691E4A2051000
8000000000000000EEDA1E4A2051000010000000000000076BA1ED2A2387C1D6
E201046B0BC1D6E20104684E2050D6F6E6478684E20409756162784E2040A464
948584E205034053544453CE2284E208014C4D444144554F3AFE22D9D209C2A2
66BC176BA1B21305DF229C2A2DA5E1AE8C1DBBF13CE229C2A276BA178BF1233A
2D5CE1AFE22D9D208DBF14B2A2DBBF19C2A276BA1DBBF1B21305DF22DBBF1C42
323FBF193632B2130AC200607454E43414C460D9D20E163247A20E4A20510000
000000000000000E4A20510000000000000000000B21300F2E184E2080D4F4E4
458424F48584E2030D4F49584E2050D6F6E647866C7D1C2A20700000276BA184
E204097561627B0BC176BA19C2A2DA5E178BF18B9C18DBF1E4A2051000380000
0000000000DBBF190DA1E4A2051000200000000000000050FA1E4A2051000200
0000000000000ED2A2387C1634E1DBBF1E0CF1AE8C184E20806494C4C4441495
35743A24A5A193632B2130081004044F475C44047A20C2A20B00003555E4C2A2
0B0000D4F4E4C2A20B0000455554C2A20B0000755444C2A20B0000458455C2A2
0B0000642594C2A20B0000351445B213068000304494D43047A2033920100000
0000000130339201000000000000820339201000000000000130339201000000
0000000303392010000000000001303392010000000000000303392010000000
0000013033920100000000000013033920100000000000003033920100000000
0000130339201000000000000030339201000000000000130B21300110030D4F
4953047A20C2A2031000A414E455142595C2A20510006454242555142595C2A2
0F0000D414253484C2A20F000014052594C4C2A20B0000D41495C2A20D0000A4
55E454C2A20D0000A455C495C2A2011000145574553545C2A207100035540545
54D4245425C2A2031000F43445F4245425C2A2051000E4F46554D4245425C2A2
05100044543454D4245425B2130021008014C4D444144554F380D9D20E1632FD
332D9D2078BF184991B2130F1732D9D203FBF14B2A2B21305BF22D9D203CE227
8BF1AFE22D9D20829919C2A26C7D1279E1B21305BF22D9D203FBF14B2A2B2130
5DF22B21305DF2293632B21309B00040C405952540D9D20E16321C432D6E2010
97E1632D6E201097803A2D4EB1F88E1D6E201097339202000000000000010D4E
B1387E1D6E201097339202000000000000040D4EB1F88E1908E1EF53293632B2
1305A000402544F47540D9D20E163284E20403544F47584E204044F475C4DBBF
14BAC19C2A290DA193632B213025000403544F47540D9D20E16324B2A2299919
C2A23F2A2C58C193632B2130930003044F47530D9D20E16322189184E2040354
4F47593632B213023000303414C430D9D20E163284E2050548505444584E2040
A46494854563284E20409756162797632DCC024563284E2050D6F6E647869763
2DCC024563284E203046169797632DCC0284E20607454E43414C493632B2130B
A00040053414C440D9D20E1632634E104B0235EE18DBF193632B21304300020D
4D820D9D20E16323CE2284E2050D6F6E647869C2A276BA178BF1339201000000
000000210D5CE1AFE22D9D208DBF19C2A24563284E204097561627976329C2A2
B4402B21305DF224563284E2050D6F6E6478697632DCC0284E20607454E43414
C493632B2130FC00020E8D420D9D20E16323CE2284E2050D6F6E647869C2A290
DA178BF19C2A2EBBE1AFE22D9D208DBF13392010000000000002104563284E20
4097561627976329C2A283502B21305DF224563284E2050D6F6E6478697632DC
C0284E20607454E43414C493632B2130FC0002095D820D9D20E16324563284E2
04097561627976329C2A2B440284E20607454E43414C493632B21302500020E8
9520D9D20E16324563284E204097561627976329C2A28350284E20607454E434
14C493632B213025000403455252540D9D20E16322189184E20303414C493632
B2130AB41"
[CUT HERE]

Directory object ASCII RPL listing
----------------------------------
%%HP: T(3)A(D)F(.);
DIR
  CURR
    \<< DATE CAL
    \>>
  \<-Y
    \<< 'year' 1 STO-
GENCAL
    \>>
  Y\->
    \<< 'year' 1 STO+
GENCAL
    \>>
  \<-M
    \<<
      IF month 1 -
DUP 1 <
      THEN DROP 12
'year' 1 STO-
      END 'month'
STO GENCAL
    \>>
  M\->
    \<<
      IF month 1 +
DUP 12 >
      THEN DROP 1
'year' 1 STO+
      END 'month'
STO GENCAL
    \>>
  PCAL
    \<< PICT RCL PR1
DROP
    \>>
  CAL
    \<< EXPDT JFIX
'year' STO 'month'
STO 'day' STO
GENCAL
    \>>
  DOW
    \<< DATE SDOW
    \>>
  SDOW
    \<< 0 TSTR 1 3
SUB
    \>>
  RDOW
    \<< SDOW DOWL
SWAP POS 1 -
    \>>
  LPYR
    \<< \-> y
      \<< y 4 MOD NOT
y 100 MOD AND y 400
MOD NOT OR
      \>>
    \>>
  ALMDATE?
    \<<
      IFERR DUP
FINDALARM
      THEN DROP2 0
      ELSE
        IF DUP
        THEN
RCLALARM 1 GET ==
        ELSE DROP2
0
        END
      END
    \>>
  MOY { "JANUARY"
"FEBRUARY" "MARCH"
"APRIL" "MAY"
"JUNE" "JULY"
"AUGUST"
"SEPTEMBER"
"OCTOBER"
"NOVEMBER"
"DECEMBER" }
  DIM { 31 28 31 30
31 30 31 31 30 31
30 31 }
  DOWL { "SUN"
"MON" "TUE" "WED"
"THU" "FRI" "SAT" }
  GENCAL
    \<< { # 0h # 0h }
PVIEW MONTHBOX MOY
month GET " " +
year \->STR + 1 \->GROB
DUP SIZE DROP # 83h
SWAP - # 2h / # 2h
2 \->LIST PICT SWAP
ROT REPL FILLDAYS 7
FREEZE
    \>>
  FILLDAYS
    \<< 1 month year
JFIX CPSDT RDOW 0 1
DIM month GET
      IF month 2 ==
year LPYR AND
      THEN 1 +
      END
      FOR d PICT 3
PICK R\->B # 12h *
# 6h + 3 PICK R\->B
# 8h * # 10h + 2
\->LIST d \->STR d
month year JFIX
CPSDT
        IF ALMDATE?
        THEN 1 CHR
+
        END 1 \->GROB
REPL SWAP
        IF 1 + DUP
6 >
        THEN DROP 0
SWAP 1 + SWAP
        END SWAP
      NEXT DROP2
    \>>
  MONTHBOX
    \<< # 83h # 3Eh
BLANK PICT STO {
# 2h # 0h } { # 80h
# 0h } LINE { # 2h
# 0h } { # 2h # 3Dh
} LINE { # 80h # 0h
} { # 80h # 3Dh }
LINE # Eh 1 7
      START # 2h
OVER 2 \->LIST OVER
# 80h SWAP 2 \->LIST
LINE # 8h +
      NEXT DROP
# 14h 1 6
      START DUP
# Fh 2 \->LIST OVER
# 3Eh 2 \->LIST LINE
# 12h +
      NEXT DROP
# 5h 1 7
      FOR i DUP
# 8h 2 \->LIST DOWL i
GET 1 3 SUB 1 \->GROB
PICT 3 ROLLD REPL
# 12h +
      NEXT DROP
    \>>
  CPSDT
    \<< 10000 / SWAP
IP + 100 / SWAP IP
+
    \>>
  EXPDT
    \<< DUP IP SWAP
FP 100 * DUP IP
SWAP FP 10000 *
    \>>
  JFIX
    \<<
      IF -42 FC?
      THEN 3 ROLLD
SWAP 3 ROLL
      END
    \>>
  day 23
  year 1990
  month 10
  PPAR {
(-6.5,-3.1)
(6.5,3.2) X 0 (0,0)
FUNCTION Y }
END