taff@venus.ucsc.edu (Thomas Affinito,,,4582136) (07/12/88)
{this is a lonng post with program stuff in it ... you might want to Save it} The 411 (Directory Assistance) System Version 3 for the HP 28S copyright Tom Affinito 1988; these programs may be used, modified, copied, and distributed by individual users and user groups; they may not be published in non-user group media **************** Introduction A hierarchical memory structure CAN provide a nice method for organizing the ever-accumulating wealth of variables an active user creates for himself. More often than not however the user spends too much time using ORDER and going up and down the path trees trying to find where some particular variables are. My first 28S programming project was to tame this hierarchy with an operating system built on top of the tree structure so that the user would be more or less freed from traversal commands. My idea was to implement a workspace concept (ala APL) with specific properties: 1: the user should have simple commands to automatically create (BUILD) and disassemble (CRUSH) a workspace 2: the workspace would act as a test bed for developing and playing with new programs and ideas 3: finished programs and variables could be removed from the USER menu (HIDE) and pushed into a parent directory from which they could still be accessed; additionally, programs and variables of more general utility could be pushed to an even higher parent directory which would be visible to all created workspaces (STALL, short for "install") 4: main operating system commands should be assessed through the custom menu for ease of use; additionally, the user should be able to create specific labels that will always be loaded when the particular workspace is activated (SLAB); general labels (present for all workspaces) should also be possible (GLAB); thus the user can HIDE or STALL all his programs, and SLAB or GLAB the main applications, which gets everything out of USER space, keeps all the utilities opaque, and gives some transparency to the applications 5: the user should be able to switch from workspace to workspace with simple commands; tree traversal should be completely eliminated 6: the operating system should not take up too much memory Whether I have achieved these goals is up for grabs....though I certainly feel the system is pretty good! It has been thoroughly debugged, is filled with interesting utilities, is easily customizable, and only takes up slightly more than 2K (a small price to pay with the 28S). This is the system I use for all my program development. I am interested in all comments/criticisms/ improvements to this system .... please send me email, and I'll post summaries to the net when warranted. ******************* Version 3? After programming on the 28C for six months, I was thrilled when the 28S came out and bought it immediately. 411 was created to manage my program development style. After reading Wlodek's book ("Customizing Your HP 28"... which I recommend though it doesn't really have much specific 28S stuff) I realized that I had to move the operating system from the home directory to a subdirectory so that a could keep all my PEEK and POKE programs in the HOME directory. This led to some increased generality and Version 2 arose. Three days ago I got Bill Wickes book ("HP 28 Insights" ... highly recommended ... it's basically Bill's hybrid expansion of the Owner's Manual and Reference Manual, with some interesting suggestions on how to use the calculator that you probably wouldn't have thought of ... like how to make Solver variables act like constants!) Some of his programs duplicated utilities I had created, which is expected. In order to make 411 more accessible I changed some of my programs to have the names he used, and used his algorithms instead of mine. To wit: UP -- This is given on page 83 of his book, and is also in the HP Owner's Manual; my UP program originally returned the PATH it had just left to the stack....so my programs had pairs of UP and DOWN (which executed a path on the stack) when I did traversal. DOPATH -- This is given on page 84; my program to do this was called DOWN, but I changed the name to conform; my algorithm is not that given by Wickes...mine uses utilites Bill does not include in his book, and mine is more general as it will execute a list or a name. Purge, Clusr -- I had a single program (actually a string) which did a complete directory clear (called XCL for extra clear)...Bill's Purge does the same thing, so I have used his names and algorithms....with the exception that Clusr is put into a string object! I did this for protection; having a key that can wipe out ALL of your memory if pressed is TOO DARN DANGEROUS! I almost lost everything when I was developing my XCL program! So you do Clusr STR-> to do this program, which can not be accidently pressed by a fumble-fingered programmer. ************* What To Do The end of this post has all the program listings and variable defaults; just type them in! Just to prevent some possible confusion though: In the Home area you store the program ON411, and create the directory ->411; thus the HOME area is free to put all those programs that need to access the top of memory as Wlodek explains (in a sense, the HOME area becomes the "Assembly/Machine Language Experiment Area". In the ->411 directory go all the remaining things, except that you must create a directory here called UTIL and store GU.LS in it. The "" you see in some programs are just two quotes...which I happen to use as separators in the custom menus. The variables are listed in the order in which they appear in my USER space....organized from variables to high level commands to low level utilites. You might want to enter these in reverse order and use the USER menu to enter previous utility names for you. *********** The Directory Layout -- What This Program Does Say you create two workspaces named PROB and STAT (how to do this is described in the next section). 411 creates the following directory structures for you: HOME :: :: ->411 :: :: UTIL <- place general utilities here // \\ // \\ // \\ :: :: :: :: PROBUTIL STATUTIL <-- place specific utilities here :: :: :: :: WORK WORK ^ ^ | | do your prob do your stat work here work here 411 automates the creation, destruction, and traversal of these memory structures. It also automates movement of completed programs/objects into the specific utility areas or into the general utility area. It also controls workspace specific changes to the custom menu so that specific and general applications can remain transparent by being labelled in this menu. SideNote: This type of structure is the same as that suggested by Wickes on p.77 of his book. As I skimmed the book initially I feared he would provide programs to do what 411 does, making all my effort for nought. Fortunately he does not! Thus I hope this post can supplement and illustrate the ideas presented in his book, and help all net-users manage their directories in a manner approved by the Master. ********** How To Use It Starting Up: MAIN, ON411 MAIN creates a custom menu of all current workspace names followed by the commands EXIT, BUILD, and CRUSH. From this menu you can go to any workspace by pressing the workspace's name....you can also execute any of three commands listed above. MAIN is also available in the custom menu once you are in a workspace; pressing MAIN is usually done when you're finished using one workspace and want to go to the main menu to see the other spaces you can go to, or to use one of the BUILD/CRUSH/EXIT commands.. If you are in the HOME directory, activate 411 thru ON411, which goes into the appropriate directory and executes MAIN for you; after you have EXITed 411 and returned home, ON411 is placed on the custom menu for your conveniance. Leaving 411: EXIT EXIT takes you HOME and sets up a custom menu with ON411 in it. Leaving a Workspace: MAIN, WOFF MAIN brings you to the main menu. WOFF (Workspace Off) is used at the end of the day to move you to the main menu, clears the stack, and reset the flag modes you like. Building new workspaces: BUILD Type in a name for your space, then BUILD. After a while the MAIN command menu will be activated with a label for your new space. Enter your space by pressing its name. Go back to MAIN by choosing the custom menu and pressing MAIN. Removing old workspaces: CRUSH Type in the name of an existing space, then CRUSH. All variables and subdirectories associated with your workspace are PURGED, and the label is removed from the custom menu. Hiding variables: HIDE, STALL, SEEK To have variables executable in your workspace, but hidden from the USER area, put all of their names in a list and execute HIDE from inside your workspace area. To have variables executable by all workspaces, use STALL instead of HIDE. To retrieve variables that have been HIDEn or inSTALLed, use a list of the variable names followed by SEEK. SEEK stores the retrieved variables in the current directory....but it does not change any specific or global labels so you might want to LABOUT these too. Controlling Custom Menu : SLAB, GLAB, LABOUT SLAB takes a list and adds the objects in it to the Specific command list. Whenever you are in this workspace, you will see any commands you have SLABbed as the first commands in the custom menu. This is generally used in the following way: let's say I've got a specific application program called APP which uses specific utilities U1, U2, and U3. I've debugged it thoroughly and it's ready for use, so get all of this stuff out of the USER area by {APP U1 U2 U3} HIDE, then make APP visiblle in the command/custom menu by {APP} SLAB. (You could alternatively type in 'APP' SLAB. HIDE, STALL, SEEK, SLAB, GLAB, and LABOUT can take a name instead of a one element list. So can MOVE and the utilities DELL and VL->S.) GLAB works similarly for the Global command list which will effect all workspaces. LABOUT removes a list from the Specific and General command lists. Moving Variables To Another Workspace: MOVE Type in a list of variable names, then the name of the space you want to move to, then MOVE. The benefit of this over the sequence "{variable name list} VL->S 'name of other workspace' EVAL S->VR" is that this latter sequence will cause execution of SWON and WON which could be modified to do strange things (like RESET) which could blow the stack. NOTE: MOVE DOES NOT purge the original copies of the variables. *********** Illustrated Example OK, you've just typed in 411...so let's go! HOME we're at the top level now, so if you want to do some PEEK and POKE programs go right ahead....if you're not into that sort of thing say Goodbye to the Home directory because you'll never need to see it again! ON411 we're in the system now. No workspaces exist, but the three commands are present along with the little delimiter that separates workspace names from the commands. Let's create four workspaces: PROB to hold all my probability programs and work, ML to hold some machine-learning stuff, TEST to just mess around in, and WIX to hold all the programs I type in from the Bill Wickes' book. 'PROB' BUILD 'ML' BUILD 'WIX' BUILD 'TEST' BUILD as we do these commands, the workspace names appear in the custom menu. Let's do some probability work. PROB suddenly we're in the blank USER menu of our new workspace. Activate the custom menu and you'll see the commands HIDE, MAIN, etc., as well as some initial delimiters that will separate your specific PROB labels from general labels. Return to the USER menu. 3 4 5 'A' STO 'B' STO 'C' STO we're creating some dummy variables to demonstrate the data hiding features. In real life, we would hide utility programs and useful applications that used those programs. 'A' HIDE 'B' STALL A and B dissappear from the USER menu! A B The numbers 5 and 4 return! A and B still exist...they're just hidden. Now let's go to a different workspace. Activate the custom menu, then MAIN WIX Once again a blank USER screen faces us...we're in the WIX workspace now. A B C A returns 'A' because the WIX workspace can't see the 'A' that was HIDEn by PROB; similarly, WIX can't see the 'C' that exists in PROB; however WIX CAN see 'B' which was inSTALLed as a general hidden object. Thus we learn three things: 1) workspaces are separate and independant from each other, 2) HIDEn objects are still local to a workspace, though they are removed from the USER area, 3) STALLed objects are hidden and executable from all workspaces. Let's go back to PROB the fast way: PROB The PROB USER menu reappears. Now let's pretend that A and B are important application program that we want to execute by key from the PROB space. { A B } SLAB The Custom Menu is on and you'll see A and B appear on keys. These will always remain as keys in the PROB space until we remove them, or we destroy (CRUSH) the PROB space. WIX Go to the Custom Menu and you won't find A and B keys...SLAB only does specific workspace labelling. PROB Let's remove B as a specific label and make it a global label. 'B' LABOUT The Custom Menu turns on and B has disappeared as a label. The variable still exists however. 'B' GLAB Notice how the position of 'B' has shifted...this is where global labels appear. WIX Go to the Custom Menu. B is there on a key! Global labels appear in all workspaces. Note that you can make anything that can be put into a list a label. Note also that just because 'B' is a global label is not a guarantee that 'B' is a globally hidden variable (though this is how you should manage GLAB and STALL in general). Labelling (GLAB, SLAB, LABOUT) is inndependant of hiding (STALL, HIDE, SEEK). Now let's cleanup. 'B' LABOUT 'B' SEEK These remove the global label and the global object, which would otherwise remain when the specific workspaces are removed. (This is good that they remain...we're just bringing them down to the workspace level because we're trying to cleanup a silly example!) WOFF 'PROB' CRUSH 'WIX' CRUSH 'TEST' CRUSH 'ML' CRUSH The best way to learn is to create some more examples and play on your own. Learning 411 is easy if you take the time, and will reward you in time and organization savings many times over. *********** Shortcuts And Notes As you learn the commands, you'll find that typing them in becomes easier then going to the custom menu. The custom menu is there for backup and keypress execution of your selected utilities. To go from one workspace to another, you don't have to go through MAIN or WOFF....just type in the name of the workspace you want to go to and you're there. The main menu is always there in case you forget your names. All the commands will still work even if you have created a subdirectory in your work area, or a subdirectory in your subdirectory, etc. The only problem is that if you HIDE or STALL variables that are not located in the current directory, the WORK directory, or the specific utility directory, then they will be HIDEn correctly but their original copies will still exist too in whatever arcane subdirectory they happen to reside in. This problem should never arise though if you use this utility correctly (the only need for ANY subdirectories below the WORK area is for storing simultaneous SOLVER solutions to a current EQ.) BUILD and CRUSH pop you up to the main menu. Also, BUILD and CRUSH are supposed to be infrequent commands...workspaces are for WORKING in! Workspaces should be tailored to produce efficent problem-solving environments. (Despite the next Note!) Create a DEMO workspace so when you want to show off the HP28 to your friends you can simply go there and make a big mess (creating subdirectories, changing modes, loading up the stack), then clean the whole thing up with WOFF 'DEMO' CRUSH! *********** Utility Programs You Might Want To Use (For The Programmers) BOOP Standard error tone. Make it whatever you want. S->N If the contents of a string could be interpreted as a name or an algebraic, it will convert the string to a name or algebraic. O->S Takes a delimited object and turns it into a string w/o delimiters. Works for names, lists, vectors. Purge Purges ANY variable...including a non-empty directory. Clusr Clears ALL of the variables in the current directory...including non-empty directories. Must be executed with STR->. DELL Takes a list or name in level 2, and a name of a list in level 1, and removes all occurrences of the objects in the level 2 list (or just the name) from the list in level 1. Nothing is returned to the stack. RESET Clears stack and restores favorite flag state. VL->S Takes a list of variables (or just a name) and recalls each variable onto the stack followed by its name. At the end the number of variables recalled is itself pushed onto the stack. S->VR Takes the output from VL->S and turns it into variables in the current directory. The combination of VL->S and S->VR make it easy to move programs from the HOME directory into a workspace and viceversa...though this sort of thing should be a rare occurrence. UP Moves to the parent directory. DOPATH Takes a list or name and executes it. Usually used to return to a directory whose location has been saved onto the stack via the PATH command. ********* How To Customize It (Some examples) {Apology: I should have commented my code!! But I wanted to post this fast lest I start working on Version 4. My code is not too tricky....but you are not expected to have to "understand" it to use it. If there are enough requests I might be persuaded to produce a commented version for the net; in the meantime, here are some easy solutions for customizing 411} To change the entry behavior of every workspace --- modify WON (Workspace On) all WON does at present is build the custom menu for the workspace; let's say you want all workspaces to Boop whenever you enter them: change WON to be << UCML Boop >> To change the entry behaviour of a single workspace - modify SWON (Specific WON) which is located in the specific utility directory above the current WORK area. all SWON does curently is call WON; let's say you're in the PROB workspace, and you want this particular workspace to RESET when you activate it: change it's SWON to be << WON RESET >>; note that you'll have to go UP to modify SWON. You don't like my "" menu delimiter -- remove each "" and following + from MAIN and UCML. There are specific commands you use a lot when you've EXITed 411. Modify the list in EXIT to include ON411 and the commands YOU WANT. Now whenever you EXIT a custom menu is built that is right for your needs. Your favorite flag state is different from mine. Set the calculator to the state you like, then RCLF. Store this number in FVFLG in ->411. Now whenever a RESET or WOFF happens you'll get your state. You want your programs to change the custom menu and later restore the normal workspace custom/command menu. The workspace command menu is stored in CM.M which is in the utility directory above your current WORK area. Simply do CM.M MENU to restore the custom menu after you've changed it. Accessing the menu label lists directly -- the variable SU.LS (specific utility list) in the directory above the current WORK contains that workspace's specific labels; GU.LS (general utility list) in the UTIL directory contains the global labels. ********** 411 ******* Home Directory Stuff ->411 Directory ON411 ACTIVATE DIRECTORY ASSISTANCE << HOME ->411 MAIN >> ******* ->411 Directory Stuff UTIL DIRECTORY WITH VARIABLE GU.LS IN IT GU.LS GENERAL UTILITY LIST {} WK.LS LIST OF WORKSPACES {} CM.LS LIST OF MAIN MENU COMMANDS { EXIT BUILD CRUSH } CU.LS COMMAND UTILITY LIST { MAIN WOFF "" HIDE SLAB "" STALL GLAB "" SEEK LABOUT "" MOVE } FVFLG BINARY # REPRESENTING FAVORITE FLAG STATES #8081FFD40000000h MAIN GO TO MAIN MENU << HOME ->411 WK.LS "" + CM.LS + MENU >> BUILD CREATE A NEW WORKSPACE 'name' : << HOME ->411 DUP O->S "UTIL" + -> n n.s << IF WK.LS n POS THEN "NAME IN USE" 1 DISP BOOP ELSE 'WK.LS' DUP EVAL n + SWAP STO "<<UTIL " n.s + " WORK SWON>>" + STR-> n STO UTIL n.s DUP S-N CRDIR STR-> WORK CRDIR << WON >> SWON STO {} SU.LS STO MAIN END >> >> CRUSH DESTROY A WORKSPACE 'name' : << HOME ->411 DUP O->S "UTIL" + -> n n.s << IF WK.LS n POS THEN n PURGE n 'WK.LS' DELL UTIL n.s S->N Purge MAIN END >> >> EXIT LEAVE DIRECTORY ASSISTANCE MODE << HOME { "" "" ON411 "" "" "" } MENU 23 MENU >> HIDE HIDE THE VARIABLES INDICATED BY A LIST {list} : << -> ls << PATH ls VL->S ls PURGE WORK ls PURGE UP S->VR DOPATH >> >> STALL INSTALL THE VARIABLES (HIDE IN GENERAL UTILITY AREA) {list} : << -> ls << PATH ls VL->S ls PURGE WORK ls PURGE UP ls PURGE UTIL S->VR DOPATH >> >> SEEK RETRIEVE THE VARIABLES INDICATED BY A LIST {list} : << -> ls << ls VL->S PATH WORK ls PURGE UP ls PURGE UTIL ls PURGE DOPATH S->VR >> >> SLAB PUT LIST IN SPECIFIC LABEL MENU {list} : << SU.LS + PATH SWAP WORK UP 'SU.LS' STO DOPATH UCML >> GLAB PUT LIST IN GENERAL LABEL MENU {list} : << GU.LS + PATH SWAP UTIL 'GU.LS' STO DOPATH UCML >> LABOUT PULL LABELS IN LIST OUT OF SPECIFIC AND GENERAL MENUS {list} : << -> ls << PATH WORK UP ls 'SU.LS' DELL UTIL ls 'GU.LS' DELL DOPATH UCML >> >> MOVE MOVE THE VARIABLES SPECIFIED BY A LIST INTO ANOTHER WORKSPACE {'name1' ... 'nameN} 'workspace name' : << -> nm << PATH SWAP VL->S UTIL nm O-S "UTIL" + STR-> WORK S->VR DOPATH >> >> WON WORKSPACE ON << UCML 23 MENU >> WOFF WORKSPACE OFF << RESET MAIN >> UCML USER CUSTOM MENU LIST MAKER << PATH WORK UP SU.LS "" + GU.LS + "" + CU.LS + DUP 'CM.M' STO MENU DOPATH >> UP ACTIVATE THE PARENT DIRECTORY << PATH DUP SIZE 1 - 1 MAX GET EVAL >> DOPATH EXECUTE A PATH OR NAME {path} : 'name' : << O->S STR-> >> VL->S VARIABLE LIST TO STACK {'name1' 'name2'...} : obj1 'name1' obj2 'name2'... N << {} + -> ls << 1 ls SIZE FOR j ls j GET DUP RCL SWAP NEXT ls SIZE >> >> S->VR STACK OF VARIABLES TO VARIABLES obj1 'name1' obj2 'name2' ... 'nameN' N : << 1 SWAP START STO NEXT >> RESET CLEAN UP STACK AND RESTORE MODES << CLEAR FVFLG STOF >> DELL DELETE A LIST OF OBJECTS FROM A NAMED LIST {obj1 ... objN} 'name of list' : obj 'name of list' : << SWAP {} + -> lsnm erls << 1 erls SIZE FOR j erls j GET lsnm EVAL WHILE DUP 3 PICK POS DUP REPEAT SWAP LIST-> DUP DUP 3 + ROLL - 2 + ROLL DROP 1 - ->LIST END DROP lsnm STO DROP NEXT >> >> Purge PURGE ANY VARIABLE 'name' : << 31 SF IFERR PURGE THEN DUP EVAL Clusr STR-> UP PURGE END >> Clusr CLEAR ENTIRE DIRECTORY "VARS LIST-> 1 SWAP START Purge NEXT" O->S DELIMITED OBJECT TO STRING {list} : "list" 'name' : "name" << ->STR DUP SIZE 1 - 2 SWAP SUB >> S->N STRING TO NAME "name" : 'name' << "'" SWAP + STR-> >> BOOP ERROR SOUND (JUST LIKE THE INTERNAL SOUND) << 340 .07 BEEP >> ********** Hope you enjoy this utility as much as I do! Thomas J. Affinito UC Santa Cruz, Board of Computer & Information Sciences Internet: taff@saturn.ucsc.edu or taff%saturn@ucscc.ucsc.edu Bitnet: taff@ucsccrls (probably) Postal addr: Box 14 Grad Student Housing, 401 Heller Dr., Santa Cruz CA 95064
mbk@hpsemc.HP.COM (Miles Kehoe) (07/16/88)
Thomas: Do you mind if I post your note on the hp28 411 code onto the Compuserve HP Sig? Please let meknow... Miles