
			     List ver 2.1
			    ==============

		 A general list handler by B.Fahller
		=====================================

I have long dreamt of having a note book, address list, calendar, and
calculator in the same box. When I got my HP28S I thought I could realize this
idea. The first prototype program was a real mess, but I won't bore you with
the story about that one. I put version 1.0 on gmuvax2.gmu.edu a month or
two ago, but I was never very satisfied with it. Now when Alonzo Gariepy
posted his smooth memory scanner I knew how to make it better. I thought I
had the program finished two weeks ago, but gosh, was I wrong? Only a few
days ago I thought "Why am I having two almost identical programs. One for
keeping lists, and one as a calendar." My conclusion was that there was no
reason to, so I've made the corrections necessary for having both programs
in the same program.

To run this program you need a machine code program called SCR, written by
Alonzo Gariepy and Stephen A. Luse's clock program.

Let's assume you've already typed it all in. I'll give you a little lesson on
how to deal with this program package.

Quite obvious is that you want a phone/address list.
type 'PHONE', ENTER and [USE]

Beep!! Do we want to create this list? Yes we do. Press "Y".
Now the top line should read "Empty list" in reversed video. It's quite
obvious that you will want to have the address of the programmer of this
delicious utility. So. Enter the following strings
"Bjorn Fahller"
"Trollnasvagen 3A
"S-951 61 Lulea"
"SWEDEN"
"phone +46 920 26870"
"MAIL d89-bfr@sm.luth.se"

[ADD]

Viola! There's a line with my name on it. Unfortunately only a few lines of
the information you worked so hard typing in is shown. Now for the real
surprize.

[SHOW.]

Smooth scrolling. If you want to stop the scrolling you just have to press
a key. When you press the next key, the scrolling will continue.

Lets add Bob Periano to our list.

"Bob Periano"
"George Mason University"
"4400 University Drive"
"Fairfax, VA 22030"
"USA"
"EMAIL periano@gmuvax.gmu.edu"

[ADD]

Oh. We forgot his phone nr. Well doesn't matter that much. Enter

"Bob Periano"
"phone (703)-323-2549"

[ADD]

[SHOW.]

Well. What do you know. It's there. Oh. His email address is a bit too long.
Hmm. What can be done about that. Well. You're a clever guy and you know an
interet address when you see one. No need to explain that it's his EMAIL
address.  Press

[EDIT]

Seems like editing a list. That's correct. Now change the EMAIL string to
"periano@gmuvax.gmu.edu". Press

ENTER.

If you have messed something up, and you're not at all satisfied with the
editing, you can drop it, and Press [EDIT] again. If you are satisfied with
your editing you just press [EDIT]. If you decide that maybe editing isn't
such a good idea after all, you can drop it, and press [SHOW.]

Now we can enter Eric Toonen to the list (You know. Him with the SYSEVAL
addresses).

You know what to do. The address is.

Eric Toonen
Djept-Zuid 6
5502 RP Veldhoven
THE NETHERLANDS

And of course you want to add some of your friends. Do so.

Ah. You have noticed that you can "walk" up and down the list with the
[PREVN] [NEXT] keys. Suppose you want to go fast in the list. Suppose you
are in the end of the list, and you want to see my address.

Press "Bj" ENTER and [FIND]. Unless some of your friends is named Bj-
something, you will see my name.

15 minutes break!
         .
         .
         .
         .


Press NEXT [Not the menu key] and quit. We are now going to play with the
calendar. The calendar list is called APP for appointment.

type 'APP' ENTER [USE]

Of course we want to create this list. First we try some relative dating.


0
"Find some bugs"

[ADD]

Now you will see todays date as the head line. The zero means that the date
should be calculated relative from today. Today + 0 days is still today.

4
"Mail bug report to"
"d89-bfr@sm.luth.se"

[ADD]


Now try some entries in the near future. The program works just as with the
phone list.

Now let's try some absolute dating. The format of date is YYYYMMDD. The reason
for that format is 1. It's the one I'm used to. 2. It makes life easier for
the sorting algorithm. 3. It's quite close to ISO's recommendations :-).

19891225
"X-mas day"

Maybe it's time for a little note. Old entries are deleted to save memory.
                                   =======================

[ADD]

This isn't that amusing, is it? Let's go back to the PHONE list. Press
the next key and [QUIT], or type quit directly.

'PHONE'
[USE]

Back in the phone list.  You're probably fairly tired of having me in your
phone list now. Lookup my name.

DEL

You will be asked if this is really what you want to do. The reason is that
I had the DEL function on a menu key earlier, and used to delete elements
from my list every now and then. I still don't think there's any harm in it.

I think I have explained the whole program now. By the way. Don't forget
to delete the silly note about X-mas day, in the 'APP' list.

Enjoy.

Here comes the programs
------------------------------------------------------------------------------
First some very neat small programs to store in the HOME directory.

CODE				COMMENTS

SPACES[EF38]
<<
"                       "       ; 23 spaces
SWAP 1 SWAP SUB
>>


BEP[22A1]			; Will embarrass you the way you're used to.
<< #22BE0h SYSEVAL
>>


SHOWMENU[F847]			; A MENU command that displays the menu under
<< DUP LIST-> -> n		; Execution.
  <<
    WHILE n 6 >			; Since the syseval in the end only takes six
    REPEAT n 1 - 'n'		; strings as argument, we must get rid of the
STO DROP			; others.
    END				; As a matter of fact this syseval takes
    WHILE n 6 <			; exactly six strings as an argument, so we
    REPEAT n 1 + 'n'		; might have to fill up with empty strings.
STO ""
    END 1 6
    START ->STR DUP		; Ah. the argument to here wasn't in string
SIZE 1 - 2 SWAP SUB		; form. Better change that.
6 ROLL
    NEXT #3F5FBh
SYSEVAL MENU			; Maybe a good idea to install it as a custom
  >>				; menu too. Otherwise it just looks fancy
>>				; without doing any good.


KEYIN[5678]			; Waiting for a key
<<
  DO
  UNTIL KEY
  END
>>

NVIDEO[52B5]			; Makes DISP show lines the normal way
<< # 18789h SYSEVAL
>>
IVIDEO[A2B4]			; Makes DISP show lines in inverse video.
<< # 18778h SYSEVAL
>>

------------------------------------------------------------------------------
The programs.

USE [83A6]
<< 0 'NAME' STO ->		; Set correct display mode and store the name
name				; of the list
  << DEPTH ->LIST		; Save the stack and flags.
'STACK' STO RCLF
'FLAGS' STO 64 STWS
31 CF name
    IFERR RCL			; Is there a list with this name?
    THEN
"Unexistent list" 1		; Apparently not. Do we want to create this it?
DISP "Create ?" 2
DISP BEP KEYIN
      IF "Y" <>
      THEN QUIT CLMF		; Nope. Must have typed it wrong.
      ELSE CUSTOM		; Yes. Fix the menu, and create an empty list
SHOWMENU { } name		; with the proper name, and save the name in
STO name 'LIST' STO		; 'LIST'
1 'NR' STO 'USE' DUP		; Make sure we start with element #1, and then
RCL SWAP DUP PURGE		; move this program to pos 1 in the menu
STO SHOW.			; Now show the content of the empty list
      END
    ELSE DROP name		; Now the list existed. Drop it's content.
      IF 'LIST' RCL		; Is it the list we used last?
SAME NOT
      THEN 1 'NR'		; No. Better start with element #1 then.
STO
      END
      IF name 'APP'		; Is it the appointment list?
SAME
      THEN APP DUP		; But yes it is.  Calculate todays date and
DATE D->A BINFIND APP		; find nearest date in the list
SIZE SUB 'APP' STO 1		; Delete old stuff and store the list.
'NR' STO			; Make sure to start with the first element.
      END name			; Store the name in 'LIST'
'LIST' STO SHOW.		; and show the content of the list.
CUSTOM SHOWMENU			; Fix the menus
    END
  >>
>>

EDIT [1F1E]
<< 0 'NAME' STO			; Fix the screen mode
  IF DEPTH			; Is there anything on the stack?
  THEN LIST SWAP NR		; yes. It should be put into the list then
SWAP PUT 'LIST' RCL		; save the list, and show the new edited
STO SHOW.			; element.
  ELSE LIST NR GET		; Nothing on the stack. Get the element to
#1BF84h SYSEVAL			; EDIT
#188A2h SYSEVAL			; Set insert mode.
  END
>>

FIND [8CA6]
<< LIST SWAP BINFIND		; Find the element nearest to the keyword
'NR' STO 0 'NAME'		; Fix the display mode and show the element.
STO SHOW.		
>>


CUSTOM [AB2E]
{ PREVNR NEXTNR			; Only the menu as I like it best.
SHOW. ADD FIND EDIT
QUIT }

SHALL [D45D]
<< LIST NR GET -> item		; Get the element and store in item
  <<
    IF item SIZE 3 >		; Are there more than 3 elements in it?
    THEN 4 item SIZE		; Show all elements starting with #4 on
      FOR i item i		; line 4.
GET 4 DISP
        IF KEY			; Check if a key is pressed between the lines.
	THEN DROP		; We don't want to know what key it was
KEYIN DROP			; Just wait for another key
	END SCR 1 7		; Scroll the screen 8 times
	START .1
WAIT SCR
	NEXT			; Show next line.
      NEXT CUSTOM		; Better fix the menu again.
SHOWMENU
    ELSE SHN			; Not more than 3 lines! It's not my biz then.
    END
  >>
  IF KEY			; Take care of extra keys
  THEN DROP
  END
>>

SHN [8128]
<<
  IF LIST SIZE			; If the list isn't empty, we get the element,
  THEN LIST NR GET		; otherwise we must tell the user that the
  ELSE {			; list is empty, because if we don't we'll hit
"Empty list" }			; an error later.
  END -> item			; Store the element in item.
  << IVIDEO 'item(1)'		; Get the first sub element.
EVAL
    IF 'LIST' RCL		; If we're using the appointment list
'APP' SAME LIST SIZE		; the date must be converted to a more
AND				; Convinient form.
    THEN A->D FMTDATE
    END DUP SIZE 23		; center the line
SWAP - 2 /  FLOOR
SPACES SWAP + 1 DISP		; And show it in reversed video
NVIDEO 2 3			; Show the following two lines in normal video
    FOR i		
      IF item SIZE i	
>=
      THEN 'item(i)'
EVAL
      ELSE ""			; Ah! If there are no more sub elements, we
      END i DISP		; create empty strings instead.
    NEXT
  >>
>>

QUIT [E52F]
<< FLAGS STOF STACK		; Restore the flags and the stack. Restore the
LIST-> DROP CM.M MENU		; menu and go back to the user menu.
23 MENU				; If you're not running Tom Affinito's 411
>>				; Directory handler you can skip the CM.M MENU
				; part.

CLR3 [7D14]
<< "" "" "" 1 DISP 2		; Quite obvious program. Clears the first three
DISP 3 DISP			; lines of the display.
>>

NEXTNR [70F7]			; Increment element pointer if we're not
<< LIST SIZE NR >		; already pointing at the first element
'NR' STO+ 0 'NAME'		; Change display mode and show the selected
STO SHOW.			; element.
>>

PREVNR [6718]			; Decrement the element pointer unless we're
<< NR 1 > NEG 'NR'		; pointing at the first element
STO+ 0 'NAME' STO		; Change the display mode and show the
SHOW.				; selected element.
>>


DEL [EF22]		
<< "SURE (Y/N) ?" 3		; Sure we want to delete this element?
DISP KEYIN
  IF "Y" ==			; Yes we do. 
  THEN LIST DUP 1 NR		; Add all elements before the one to delete
1 - SUB SWAP DUP		; with all elements after the one to delete
SIZE NR 1 + SWAP SUB		; and store them as the new list
+
  END 'LIST' RCL STO		; Change display mode, point to previous
  IF NR 1 >			; element and display it.
  THEN 'NR' 1 STO-
  END 0 'NAME' STO
CUSTOM SHOWMENU
SHOW.
>>

ADD [3F07]
<< DEPTH 1 - ->LIST ->		; Find the head and the info.
head new
  <<
    IF 'LIST' RCL		; Are we using the appointment list?
'APP' SAME
    THEN			; Yes. the head is a date then
      IF head 10000		; If the value is < 10000 it's most probably
<				; a relative date. Calculate what date is
      THEN DM DKOR -		; really meant.
707788800 / head +
JC2 D->A 'head' STO
      END
    END
    IF LIST SIZE NOT		; IF the list is empty then just store the
    THEN head 1			; head and info as the new list.
->LIST new + 1 ->LIST
1 'NR' STO
    ELSE LIST head		; Find the most probable position for the
BINFIND -> n			; element.
      <<
        IF LIST n		; Is the head of that element equal to the
GET DUP 1 GET head		; head we entered?
==
        THEN new +		; Yes. Just append the info then.
LIST SWAP n SWAP PUT
        ELSE DROP		; No. Drop it. Is our head > the element
	  IF LIST n		; pointed at?
GET 1 GET head >
          THEN LIST		; Yes. Insert the head and info just where
1 n 1 - SUB head 1		; we are.
->LIST new + 1 ->LIST
+ LIST DUP SIZE n
SWAP SUB +
          ELSE LIST		; No. We must be in the end of the list.
head 1 ->LIST new + 1		; Just put our head and subject last.
->LIST + n 1 + 'n'
STO
          END
        END n 'NR'		; Change the element pointer to point at us.
STO
      >>
    END 'LIST' RCL		; Store the list.
STO
 >> 0 'NAME' STO		; Change display mode and show the element.
SHOW.
>>

BINFIND [9139]			; Hardly any idea to explain. It's just a
<< -> list head			; binary search.
  << 0 list SIZE -> l
u
    <<
      WHILE l u -
ABS 1 >
      REPEAT
        IF u l + 2 /
DUP list SWAP GET 1
GET head <
        THEN 'l' STO
        ELSE 'u' STO
        END
      END u
    >>
  >>
>>

SHOW. [9762]
<<
  IF NAME			; If the rest is about to be displayed then
  THEN 0 'NAME' STO		; toggle display mode, and show the rest.
SHALL
  ELSE 1 'NAME' STO		; otherwise show the head and toggle the
SHN				; display mode.
  END
>>

A->D [4232]			; converts appointment date format to
<< 10000 / DUP IP		; Luse's date format
1000000 / SWAP FP
100 * +
>>

D->A [92DF]			; converts Luse's date format to appointment
<< 100 * DUP FP			; date format.
100000000 * + IP
>>
			
-----------------------------------------------------------------------------

The necessary variables

LIST
'DUM'

NR
0

NAME
0

FLAGS
#0h

STACK
{ }

----------------------------------------------------------------------------
If you're running Tom Affinito's 411 directory handler (which I strongly
recommend), I advice you to hide all programs except use. Keep the variables
in the workspace.

If you have any comments about this program I'd like to know. If you give me
good ideas of changes, I'll start working on version 3. This program is
written by me for my needs. You're of course very welcome to modyfy it to
fit your needs. That's why I've commented the code. You're free to do whatever
you want to with it, except earning money on it, and preventing it's your
program. Except from that. DO WHAT YOU PLEASE.


----------------------------------------------------\
SNAILADDRESS       MAILADDRESS         VOICEADDRESS  \________________________
Bjorn Fahller      d89-bfr@sm.luth.se  +46 920 26870 / Please DO comment on
Trollnasvagen 3A /----------------------------------/ my language.
S-951 61 Lulea  / The more you know,
SWEDEN  /------/ The better you realize
-------/        How little you know.


---------------------------------------------------------------------------

Alonzo Gariepy's SCR Program (For those of you who doesn't already have it)
Be careful when you enter these programs. I have included checksums to
prevent errors, just because an error in these programs can very probably
lead to a memory lost and we all know how fun that is. I took the liberty
of cutting out explanatory parts, and programs that are not used.


> The following MBAG program creates the BAG program in the HOME directory.
> Once it is created, BAG can be moved elsewhere via RCL and STO.  Because
> it contains a System Object, you cannot edit BAG.  Any changes can be
> made by editing MBAG and rerunning it.  You can modify anything up to the
> first hex number.  Usage is:  #value #address BAG
>
> MBAG
> <<
>   << SWAP OVER # 0h AND OR SWAP
>     # D6471341301231h
>     # D6461431471741h
>     # D6631581631641h
>     # C67E16514610D08h
>     # D6031241961031h
>     # C62412313111451h
>     # CFF4AC808461027Eh
>   >>  
>   HOME 'BAG' DUP PURGE STO
>   # 301231000B102C96h
>   # CFF40h #CFFF1h SYSEVAL
> >>
>

Checksum [34AB]

> SYSEVAL solves the bootstrap problem by calling into BAG to patch the 
> sequence of 7 numbers into an inline machine code object, yielding:
>
> BAG
> << SWAP OVER # 0h AND OR SWAP System Object
> >>
>
> You can purge MBAG once you know BAG works.
>
> Alonzo Gariepy
> alonzo@microsoft


> From: alonzo@microsoft (Alonzo Gariepy)
> Newsgroups: comp.sys.handhelds
> Subject: HP28S: scrolling memory scanner (long)
> Keywords: SCAN, SCR, B->STR
>
> Here is a smooth scrolling memory scanner.  A disassembly follows.
>
> First, a machine program that scrolls the display one pixel upwards.
> You run MSCR to create SCR, the scroller.  Usage:  SCR
>
> MSCR [167F]
> << 64 STWS
>    << # 0h # 0h # 0h # 0h #0h
>    >> HOME 'SCR' DUP PURGE STO
> # 7D02C96h # CFF74 BAG
> # 37222132D301231h  # CFF7Eh BAG
> # 51FF840B118AA017h # CFF8Eh BAG
> # F61705160E0C1872h # CFF9Eh BAG
> # B113D09E9EA8ECh   # CFFAEh BAG
> # 651FD4658AA11FFCh # CFFBEh BAG
> # 1102145150E0E181  # CFFCEh BAG
> # C8084612412313h   # CFFDEh BAG
> >>
>
> yielding:
>
> SCR
> << System Object >>
>
>
> Alonzo Gariepy
> alonzo@microsoft

