Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!otello!gear!wolf!Joseph.Ervin From: Joseph.Ervin@wolf.fidonet.sublink.org (Joseph Ervin) Newsgroups: comp.sys.handhelds Subject: Re: HP48SX Phone Number Manager V1.4 Message-ID: <3700.27A0C312@wolf.fidonet.sublink.org> Date: 26 Jan 91 00:37:23 GMT Organization: Rekursive Labs sdf- Pisa, Italy Lines: 234 THEN DO @ This section of code was modified in v1.4 to handle the editing of @ addresses. For this reason, I use several IFTE commands below to @ differentiate between editing the PHNUMBERS field and the @ ADDRESSES field. INDEX DUP PHNAMES SWAP GET @ Gets the name to be modified. @ SWAP 6 FC? 'PHNUMBERS' 'ADDRESSES' IFTE @ Gets PHNUMBERS or ADDRESSES, depending on the @ state of flag 6. SWAP GET @ Gets number/address to be modified. @ @ The stack now has @ 2: name @ 1: number/addr @ Now reformat the information for the INPUT command. 6 FC? ":Number:" ":Addr:" IFTE SWAP + SWAP ":Name:" SWAP + @ Adds tags to the name and num/addr. " " + SWAP + @ Creates one long string with a carraige return @ @ to separate the name and num/addr strings. @ @ Now display this information using INPUT so the user can @ @ edit the strings. @ "Edit entry..." SWAP 0 2 \->LIST {} TMENU INPUT @ At this point, the user has been prompted with the name and @ @ number to be modified. The keyboard is in overstrike mode @ @ and the cursor was left at the end of the number. @ @ Now we must recover the new name and number from the @ @ string on the stack. @ DUP 'EDITSTRING' STO @ Save a copy of the string. IF DUP ":Name:" POS 1 == @ Test for existence of the name... SWAP DUP 6 FC? ":Number:" ":Addr:" IFTE POS @ ...and number tags within the string. DUP 'TEMP' STO @ Save location of num/addr tag. ROT AND THEN @ The user entered valid data. @ @ Update the database with new name.@ DUP 7 TEMP 2 - SUB @ Extract the modified name. @ 1 \->LIST PHNAMES SWAP INDEX SWAP REPL 'PHNAMES' STO @ Save modified name in PHNAMES. @ Update the database with the new number/address. TEMP 6 FC? 8 6 IFTE + EDITSTRING SIZE SUB @ Extract the new name/addr. 1 \->LIST 6 FC? 'PHNUMBERS' 'ADDRESSES' IFTE SWAP INDEX SWAP REPL 6 FC? "'PHNUMBERS'" "'ADDRESSES'" IFTE OBJ\-> STO 1 'DONE' STO CLEAR ELSE CLLCD 1200 .1 BEEP "Invalid Entry" 2 DISP 2 WAIT END UNTIL DONE END ELSE @ The user wants to delete the entry. @ CLEAR INDEX DUP PHNAMES SWAP GET @ Gets the name to be modified. @ SWAP PHNUMBERS SWAP GET @ Gets number to be modified. @ @ The stack now has @ @ 2: name @ @ 1: number @ @ Now reformat the information for the INPUT command. @ ":Number:" SWAP + SWAP ":Name:" SWAP + @ Adds tags to the name and number. @ " " + SWAP + @ Creates one long string with a carraige return @ @ to separate the name and number strings. @ @ Now display this information and prompt user to verify that @ @ this record should be deleted. CLLCD "Delete entry?" 1 DISP 4 DISP 1200 .1 BEEP 3 FREEZE { { "Yes" \<< 1 CONT \>> } { } { } { } { } { "No" \<< 0 CONT \>> } } TMENU HALT IF @ yes @ THEN PHNAMES OBJ\-> DROP @ Put the list of names on the stack. @ PHSIZE INDEX 1 - - ROLL DROP @ Deletes the entry pointed to by INDEX. @ PHSIZE 1 - \->LIST 'PHNAMES' STO PHNUMBERS OBJ\-> DROP @ Put the list of names on the stack. @ PHSIZE INDEX 1 - - ROLL DROP @ Deletes the entry pointed to by INDEX. @ PHSIZE 1 - \->LIST 'PHNUMBERS' STO ADDRESSES OBJ\-> DROP @ Put the list of names on the stack. @ PHSIZE INDEX 1 - - ROLL DROP @ Deletes the entry pointed to by INDEX. @ 'PHSIZE' DECR \->LIST 'ADDRESSES' STO END END ELSE 5 CF END \>> END END \>> @end case@ END @IF 2 FC?C ADDRESSES PHNUMBERS PHNAMES 3 \->LIST 'PHDAT' STO \>> @ Surrounds PHEDIT's parameters. @ \>> @ Ends the definition of PHEDIT and pushes PHEDIT on the stack @ @ to be defined later.@ \-> PHEDIT @ Defines the subroutine "PHEDIT", which edits the database. @ @ PHEDIT takes as parameters a single string which must have the @ @ value "NEW", indicating a new list should be created, @ @ or "INT", indicating the old list should be prompted as to @ whether the current list is to be added to or edited. @ \<< @ The main routine starts here. @ 64 STWS @ Sets the word size to 64. Needed for RCLF RCLF DUP 'FLAGS' STO 2 {#0d} REPL STOF @ Clear user flags. STD @ Set display to STD mode. Looks nicer. IF 'PHDAT' VTYPE -1 == THEN CLLCD "Phone Database does" 2 DISP "not exist. Do you" 3 DISP "want to create it?" 4 DISP 3 FREEZE { { "Yes" \<< 1 CONT \>> } { } { } { } { } { "No" \<< 0 CONT \>> } } TMENU HALT @ Prompt the user for yes/no @ IF THEN {} DUP 'PHNAMES' STO 'PHNUMBERS' STO "NEW" PHEDIT EVAL @ tells PHEDIT to go directly to the @ @ edit input mode on a new list @ @ After the user exits PHEDIT, control falls down to main routine below.@ ELSE "You must create a phone database before any further action can be taken." 2 DISP CLEAR 2 MENU 1200 .1 BEEP 3 FREEZE 3 WAIT 0 DOERR @ Obviously, the user is a pinhead. @ END END @ We need to start the main routine.@ 0 \-> DONE \<< @ First we need to suck in the database. @ {} DUP 'PHNAMES' STO 'PHNUMBERS' STO CLEAR @ Clear the stack, so the following DEPTH command will work. PHDAT EVAL @ At this point, we need to determine if the current database is in @ the new format used with V1.4 and later. If the database does not @ contain the list of ADDRESSES, then we need to add them and write it back @ out. IF DEPTH 2 == THEN @ We must update the database structure. CLLCD "Reformating PHDAT. Please wait..." 2 DISP 1 WAIT DUP @ Create a spare copy of PHNAMES. {} @ Put a null list on the stack. SWAP SIZE 1 SWAP FOR I "" + NEXT @ Creates a list of null strings. 3 ROLLD 3 \->LIST 'PHDAT' STO @ Adds the empty address list to the database. CLEAR PHDAT EVAL END 'PHNAMES' STO 'PHNUMBERS' STO @ copies the database in the local @ @ variables 'PHNAMES' , 'PHNUMBERS' @ 'ADDRESSES' STO @ and 'ADDRESSES'. PHNAMES SIZE 'PHSIZE' STO @ Indicates the number of names in the list. @ DO @ Here we want to ask the user whether we are searching or editing. @ "Do you want to search the list or edit the list?" CLLCD 1 DISP 3 FREEZE {{"SRCH" \<< DO PHSEARCH EVAL UNTIL 1 FS?C END CONT \>>} {"EDIT" \<< "INT" PHEDIT EVAL CONT \>>} {} {} {} {"Exit" \<<1 'DONE' STO CONT \>>}} TMENU HALT @ "INT" for PHEDIT here to tell PHEDIT to prompt the user as to @ @ whether he wants to edit (modify) the phone list or simply add to it. @ UNTIL DONE @ Keep on doing this loop until DONE. @ END \>> @ DO @ CLEAR 2 MENU FLAGS STOF @ Resets the state of the system and user flags. \>> @ Defines bounds for which PHSEARCH is defined. \>> @ Main Routine. \>> @ Main routine and procedures. \>> @ End of Program. -- WolfNet BBS Pisa (Italy) Tel. +39-50-589050 300-14.4K Baud Matrix 2:332/602.0 Joseph Ervin - via FidoNet node 2:332/602 UUCP: ...!gear!wolf!Joseph.Ervin ARPA: Joseph.Ervin@wolf.fidonet.sublink.org