From: jhmeyers@miu.edu (John H Meyers)
Subject: Print your VAR catalog! (Need to organize my HP files & dir's)
Date: 23 Mar 1997 00:00:00 GMT
Message-ID: <5h3s9m$akp$1@news.iastate.edu>
References: <33327810.6B6F@earthlink.net>
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Reply-To: jhmeyers@miu.edu
Newsgroups: comp.sys.hp48


In article <33327810.6B6F@earthlink.net>, Rod <rriech@earthlink.net> writes:

> I have a lot of files & directories stored in my HP that have become
> very disorganized, and need to be able to see them so I can sort them
> out. I would like to know if anyone has any suggestions that they might
> have done already for the same sort of problem.

The program below "prints out" a complete catalog of all your variables,
giving for each the name, size, description, and checksum (decimal).

This is similar to the "printout" you get from the HP48 in
Kermit SERVER mode, when you reqest a REMOTE DIR from your PC
(something you can do only if you have a complete Kermit on your PC,
which most terminal emulators do not provide), except that this printout
traverses your entire user memory, not just the current directory.

You can "capture" this printout by connecting your HP48 to your PC,
using your Terminal emulator (Windows [Hyper]Terminal, Kermit, etc.)
to "download" an ascii file (i.e. copy whatever is received and
appears on the screen into a file); e.g. with Kermit this is
accomplished via LOG SESSION followed by CONNECT.

Of course, you can also capture it directly on any *serial* printer
(adjust PRTPAR in the HOME directory if it doesn't look right);
you may need a "printer adapter" or "gender changer" to fit the
printer's serial connector, which is generally the "opposite" of the PC.

The majority of printers used with PC's are *parallel* printers, however,
which would require a serial-to-parallel converter to use with your HP48.

Below is a sample printout, showing that each directory's variables
are listed immediately below the directory name,
indented by one "tab stop" (4 spaces, adjustable in the program).

The format, again, is:  name, size, description, checksum(decimal);
the "size" includes the variable name, as when you do 'name' BYTES.

HOME
    PTREE 319.5 Program 38301  (the program which made this listing!)
    MATH 5619.5 Directory 44095
        FACTOR 2427 Directory 11682
            DEMO 123.5 Program 45472
            PRIME? 240 Program 22703
            FACTOR 88 Program 40935
            ...
        NUMI 206.5 Directory 20727
            INT 109.5 Program 59814
            FCN 66 Program 57151
            N 16 Real Number 3320
        SOLVE 100 Program 57618
        BASE 116 Program 44254
        SPRSH 252 Directory 41083
            SUM 133 Program 43394
            CUT 103 Program 5318
        ...

Note that this program recursively calls itself by name;
if you store it under a name other than PTREE, then you
must edit the program (near the end) to change this call.

You may use this on an HP48S/SX if you also obtain my DOLIST
program which simulates DOLIST on an S/SX (included below!)

Store PTREE in the HOME directory, and go to HOME before
starting it, in order to list your complete HP48.

%%HP: T(3); @ header for Kermit; \-> means right-arrow, etc.
@ PTREE - print "name bytes description checksum" for all VARs + sub-dirs
@ To list all user variables, go to HOME directory before starting.
\<< STD -34 SF { PR1 1 DISP } \-> p @ to both printer & screen
  \<< PATH { HOME } SAME { "HOME" p EVAL } IFT VARS
    IF DUP SIZE THEN 1 \<< DUP " " + OVER BYTES SWAP DROP +
    @ the next 2 lines append the type description and checksum:
    " " + OVER VTYPE 263 + IFERR DOERR THEN ERRM END
    + " " + OVER BYTES DROP B\->R +
    1 PATH SIZE START "    " SWAP + NEXT p EVAL @ indent, print
    IF DUP VTYPE 15 SAME THEN PATH SWAP EVAL PTREE EVAL @ sub-dir?
    ELSE DROP END \>> DOLIST ELSE DROP END \>>
\>> @ End of PTREE, 310 bytes (on stack), #959Dh checksum.

Below, at no extra charge, is a DOLIST simulator for the HP48S/SX;
profuse documentation was included in the original post, around
1996.10.17 (available via DejaNews), but is truncated here:

Stack diagram: { list N } ... { list 1 } N <<function>> --> { results }

Examples:              { 1 2 3 4 } << SQ >> DOLIST --> { 1 4 9 16 }
          { 5 4 3 2 } { 2 3 4 5 } 2 << ^ >> DOLIST --> { 25 64 81 32 }
          The "function" may also return a different number of results
          than the number of arguments in the lists, or no results at all.

%%HP: T(3); @ header for Kermit; \-> means right-arrow, etc.
@ Store in a variable in HOME named DOLIST
\<< OVER TYPE 5 == { 1 SWAP } IFT @ missing N is assumed 1 (unlike G/GX)
    SWAP 0 RND                  @ non-integer N is rounded (same as G/GX)
    SWAP OVER 2 + ROLLD \->LIST @ one list of all original arg lists
    DUP SIZE DEPTH 3 -          @ N; original stack depth
    \-> ?f ?l ?n ?d             @ function, list of arg lists, N, depth
    \<< 1 ?l 1 GET SIZE         @ all arg lists should have same size
        FOR ?i 1 ?n             @ i indexes corresponding args in each list
          FOR ?j                @ j indexes which list (1,..,N)
            ?l ?j GET ?i GET    @ get i'th element from j'th list
          NEXT ?f EVAL          @ evaluate function of N args from N lists
        NEXT DEPTH ?d - \->LIST @ final stack growth -> all into one list
    \>> DUP { } SAME { DROP } IFT @ G/GX drops any empty result list!
        @ You can omit this last faux pas, if you want a "better" DOLIST!
\>> @ End of DOLIST, 204 bytes (on stack), #E2F0h checksum

-----------------------------------------------------------
With best wishes from:   John H Meyers   <jhmeyers@mum.edu>
