Hello comp.sys.handhelds,

I wrote this set of programs a while back
and finally got them uploaded to a magnetic
medium, so I didn't think that it would
be much more trouble to post them.

These programs were written with the intention
that they would reside in their own directory,
but I imagine they will work anywhere.

The first procedure '->mcase', converts
an upper case string to mixed case.
I wrote this because I thought that
the names and addressed looked better
in mixed case.

 '->mcase'
 << -> s
  << s 1 1 SUB 2 s
SIZE
    FOR x s x x SUB
s x 1 - DUP SUB DUP
      IF "A" >= SWAP
"Z" <= AND OVER "
" !=
AND
      THEN " " OR
      END +
    NEXT
  >>
>>

The procedure 'INSERT' is used to insert the
new name/address/phone # into correct position
in the list.

 'INSERT'
 << OVER SIZE -> lst
obj s
  << lst 1 P0 1 - SUB
obj +
    IFERR lst P0 s
SUB +
    THEN
    END
  >>
>>

The procedure 'Rolodex' is the program that
calls everything else.  Press the softkey
labeled 'Rolodex' to start the program.

 'Rolodex'
 << 1 CF FAST
  DO Print Main
  UNTIL 1 FS?
  END .. subdirs	'..' and 'subdirs' are just a couple of
>>			programs in ROLODEX's parent directory
			'..' is my 'UP' prog. and 'subdirs'
			sets up a custom menu displaying 
			the subdirectories that are beneath
			ROLODEX's parent.

'Main' is the main routine (obviously) that
figures out what you want to do.

 'Main'
 << KY
  IF keys OVER POS
DUP
  THEN procs ROT
DROP SWAP GET EVAL
  ELSE DROP NL SWAP
0 3 PICK SIZE 1 +
Bsearch DUP NL SIZE
> - 'P0' STO
  END
>>

'Bsearch' is a binary search program that
searches the list on level 4 for the
string on level 3 between the upper bound
on level 2 and the lower bound on level 1.
I think that Bsearch could be fairly
easily transformed into a heap-sort.

 'Bsearch'
 << -> sl ss lb ub
  <<
    IF ub lb - 1 >
    THEN ub lb + 2 /
-> s
      <<
        IF sl s GET
ss <
        THEN sl ss s
ub Bsearch
        ELSE sl ss
lb s Bsearch
        END
      >>
    ELSE ub CEIL
    END
  >>
>>

'Print' prints the record pointed to by
'P0' 

 'Print'
 << CLLCD NL P0 GET 1
DISP AL P0 GET 2
DISP PL P0 GET 4
DISP
>>

The following three lists are where you put
your names/numbers/addresses.  I think that
the program needs one item in each of the 
lists to start up properly, but I think that
it can take care of its self from there.

 'PL'
 { phone #'s here }

 'AL'
 { addresses here }

 'NL'
 { names here }

'P0' is a real number that points to the current
name/number/address in the lists.  I can't remember
if it needs to be there for startup or not.

 'P0'
 1

The list 'procs' is all of the procedures
used by rolodex. 

 'procs'
 {
<< "Enter Name		The first procedure is for entering
"			data into the lists, INPUT was
INPUT ->mcase		posted to this group a while ago.
"Enter Address
"
INPUT ->mcase
"Enter Number
"
INPUT NL 4 PICK 0 3
PICK SIZE 1 +
Bsearch 'P0' STO PL
SWAP INSERT 'PL' STO
AL SWAP INSERT 'AL'
STO NL SWAP INSERT
'NL' STO
>>

<< CLLCD		This procedure is for deleting
"Are You Sure?" 1	someone's name/number/address
DISP KY			from the lists
  IF "Y" ==
  THEN 'NL' 'AL'
'PL' 1 3
    START DUP RCL
DUP 1 P0 1 - SUB
      IFERR SWAP P0
1 + OVER SIZE SUB
      THEN P0 1 -
'P0' STO
      END + SWAP STO
    NEXT
  END
>>

<<			This procedure is used to 
"Enter field to		edit a name/number/address
Edit   N)Name
       A)Address
       #)number"
1 DISP KY DUP
  IF "A" == OVER "N"
== OR OVER "#" == OR
  THEN NUM 11 / 3
MOD CEIL { PL NL AL
} SWAP GET DUP RCL
P0 GET "
" + INPUT
OVER
    IF 'PL' SAME NOT
    THEN ->mcase
    END OVER RCL P0
ROT PUT SWAP STO
  END
>>

<< P0 1 > -1 NL SIZE
1 - IFTE P0 + 'P0'
STO			\
>>			| These two are used to scroll forward/backward
			| thru the name list
<< P0 NL SIZE < 1 1	/
NL SIZE - IFTE P0 +
'P0' STO
>>

<< 1 SF CLMF		This procedure is used to stop 
>>			the rolodex.

<< SLOW # 18E58h SYSEVAL	This procedure is used to 
FAST				turn off the hp without leaving
>> }				the rolodex

The following list is the keys used by the program.

 'keys'		
 { "ENTER" "DEL" 
"CURSOR" "LEFT"
"RIGHT" "STO"
"SHIFT" }

'.profile' is called by my change directory program 
when rolodex is invoked. It is included here only
because it is in my hp and this is for my records also.

 '.profile'
 << 0 FIX Rolodex
>>


The following keys are used:

	"ENTER"----enter a new record into the lists
	"DEL"------delete a record from the lists
	"CURSOR"---edit the current record
	"LEFT"-----go to the previous record
	"RIGHT"----go to the following record
	"STO"------exit the rolodex program
	"SHIFT"----turn off the hp w/o leaving rolodex

	any other key will invoke a binary search for the
	position in the list pointed to by the first character
	in the name of the key (i.e. EVAL points to the E's etc.)


I haven't included any checksums because I do not use the
checksummer.  These programs are not claimed to be written
entirely by myself, its just that at the current time,
I have them in my hp.  Some of them may contain bugs, but
I think that they are all pretty reliable.  As always,
any additions/corrections/modifications are welcome.

-- 
                Never let your boss know that you're good
                        at something you hate.
Eric L. Hernes I.
hernes@plains.nodak.edu
