Path: republic.btigate.com!atl-news-feed1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!howland.erols.net!newsxfer.itd.umich.edu!newsrelay.iastate.edu!news.iastate.edu!vax1.miu.edu!JHMEYERS
From: jhmeyers@miu.edu (John H Meyers)
Newsgroups: comp.sys.hp48
Subject: User-RPL Port Tools [Storing variables on Ramcard (Slot 2)?]
Date: 1 Jan 1998 07:49:38 GMT
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Lines: 315
Message-ID: <68fhqi$fh0$3@news.iastate.edu>
References: <34A7EF8E.590A0DB5@4dcomm.com>
Reply-To: jhmeyers@miu.edu
NNTP-Posting-Host: vax1.mum.edu
Xref: republic.btigate.com comp.sys.hp48:5243

In article <34A7EF8E.590A0DB5@4dcomm.com>,
Phillip Dauben <phillip.dauben@4dcomm.com> writes:

> I just got a new ram card (512K) for X-mas.  I'm so happy that I finally
> have enough memory.  My only problem is that from what I understand,
> I can only put libraries on card slot 2 while slot one
> allows for merged memory.

  Since slot 1 accommodates only 128K, your 512K card is useful only
  in slot 2, whereas only port 1 (slot 1) can be used instead as
  "merged" memory (which appends card memory to the built-in RAM used
  for user variables, stack and temporary memory, and Port 0).

  However, you can use any port to store and retrieve multiple
  named objects, similarly to how user variables may be used,
  by using a "port-tagged name" (e.g. :2:name) for each object.

  There are some minor inconveniences to doing this routinely,
  such as the fact that port-tagged names are merely put on the stack
  when encountered during a program, rather than causing evaluation
  of the object; thus you need an explicit EVAL or RCL to execute
  programs or recall objects from ports; also, you can not STO again
  into the same name until you have purged the original object
  (conversely, this "feature" offers some protection
  which ordinary variables fail to provide).

  ARCHIVE backups do *not* include port memory, so you are also
  on your own (or can use contributed software) for port backups;
  however, both the card write-protect switch (if properly implemented
  within the card) and bank-switching logic somewhat insulate the card
  from the greater ease with which user memory can be wiped out
  (technical details from HP engineer Dave Arnett, originally posted
  on 1996/05/30, are also found in the current FAQ).

  It is therefore probably most practical to use the non-merged ports
  for libraries (which have to be stored in ports anyway), and for backup
  objects which can be swapped into and out of user memory on demand
  (including "instant" ARCHIVE backups of the whole "user" memory).

  Coupling this with other tools, such as variable hiders, library
  builders, and port object tools, gives you many different ways to
  arrange your total memory capacity to suit your own personal preferences.

> I've already moved all of my libraries to the card except for ones that
> don't seem to work on the ports other than 0 (ie java, UFL).  However,
> most of my built in memory is in the form of directories and variables.
> How do I go about storing more of my stuff on the ram card, and can I
> keep the directories intact?  Eventually if possible, I would like to
> put all of my formulas for school on the ram card.

  One of the well-advertised port object tools is PCT, but if,
  like me, you aren't committed to figuring it out and using all of it,
  or don't enjoy its particular hard-coded choices and/or overhead,
  you can still do useful things even with your own User-RPL tools,
  as we hope to demonstrate below.

> I've seen programs that say they will convert directories to libraries,
> but I've never been able to figure them out.

  See "Library-making primer" posted on 1997/11/08 (with a simple example).

  You can retrieve posts from <http://www.dejanews.com/home_sf.shtml>
  by specifying the newsgroup name, optional date range, and one or more
  "Subject" words (insert "and" between multiple words, if specified);
  the "Search filter" will then present a list of matching articles
  which you can individually select to read, save, or clip.

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

And now for a shameless non-commercial message from my new organization:

"Customizable User-RPL Software Enhancements"
(hereinafter simply referred to as CURSE :)

Just suppose you haven't yet deciphered PCT,
or perhaps you can't even unzip PCT57.ZIP (which has a
long filename containing embedded spaces) on your Win/3.1 (or other)
system, and even if you could, it duplicates tools you already
have in your Hack library, assigns its own keys and uses flags
which may conflict with your own preferences, etc.

Suppose you also didn't want to bother paying for "DirMaster"
(shareware), or couldn't even find Lloyd Standish of Costa Rica,
who offered it (per Joe Horn's posts on 1996/11/24 and 1996/11/28).

Okay, the next offering from CURSE just happens to be something which
transfers whole directories in either direction between user memory and
ports, which seems to be just what you were alluding to in your request:

Go into any non-empty directory and press DPORT -- presto,
the entire contents of the current directory are transferred
to the first available writeable port (from a list you specify)
having sufficient space.

If you return to the same directory (now emptied of any variables)
and press DPORT again, then presto -- your entire directory
is transferred right back to where it originally was.

If you would also like to compress the directory you are saving,
then just press BZDIR before DPORT; the latest BZDIR program (which
compresses an entire directory into one object) was posted 1997/11/11,
updating an earlier article of 1997/11/09 which explained how it works.

Variable-hiding is further discussed in a post about "HIDEVARS"
on 1997/11/18, including a minor modification to BZDIR for use
with variable hiders.

See also "Lightning-fast VARS command" posted on 1997/11/15
(also includes a version which lists hidden variables).

Although I have BZDIR and DPORT as labels in my "universal" CST menu
(kept in my HOME directory), you might prefer to assign them to keys
(perhaps in "1USR" fashion), or to give them some short, readily typed
zippy names, etc. -- Customizable User-RPL Software Enhancements (CURSE)
lets you make all these decisions yourself, rather than being locked
into any one author's particular choices or unmodifiable programs!

The DPORT program is listed below; unlike PCT57, which has a couple
of commands invoking internal system functions directly without
so much as checking the arguments first (how risque!),
this program detects error conditions before crashing:

"Directory Not Allowed" -- you can not move the entire HOME directory
to a port (use ARCHIVE instead, or another program found below).

"Object In Use" -- an older port backup object for the same directory
already exists (consider whether you want to purge it or keep it).

"Port Not Available" -- no listed port is writeable or has sufficient room
to save data, or the saved backup is in a read-only port & can't be purged.

"Undefined Name" -- no port object exists for this directory
(usually the result of a misguided attempt to save an empty directory).

"Bad Argument Type" -- Port backup object is not a directory.

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

%%HP: T(3); @ \-> is "right-arrow", \=/ is "unequal", etc.
@ DPORT - transfer current directory to/from a port (G/GX).

@ Modifiable for S/SX by including a separate DOLIST simulator,
@ and by using an additional DOLIST to perform PGDIR on a list.

\<< PATH SIZE 1 \<= { 298 DOERR } IFT @ Not allowed in HOME

  -55 CF @ Enable Last Args (for IFERR)

  @ Create a unique name from the current directory path:
  PATH \->STR 8 OVER SIZE 1 - SUB #5B15h SYSEVAL @ $>ID
  @ This name must end in a space, and may contain other spaces.
  @ E.g. { HOME MATH } ==> 'MATH ' ; { HOME X Y } ==> 'X Y '
  @ The [->] View key may be used to display long names in port menus.

  @ Please carefully verify this program and the SYSEVAL addresses
  @ (to prevent memory loss, etc.) -- a memory backup is also recommended.

  VARS SIZE @ Does directory contain variables, or is it empty?

  \<< @ Non-empty directory (to be transferred to first available port)
    DUP '&' \->TAG VTYPE -1 > { DROP 9 DOERR } IFT @ Already in a port
    PATH RCL @ Recall whole directory to stack
    { 2 3 4 5 6 7 8 9 } @ List of ports where we will try to store [EDIT]
    @ The above list accommodates any 128K to 1Meg card in slot 2.
    1 \<< OVER TYPE 6 == { DROP } @ Already successfully stored
      { 3 PICK SWAP \->TAG IFERR STO THEN DROP ELSE END } IFTE
    \>> DOLIST TYPE 6 \=/ { DROP 10 DOERR } IFT @ Could not store
    15 TVARS IF DUP SIZE THEN PGDIR ELSE DROP END CLVAR @ Purge vars
    @ Optional: UPDIR or UP (you can use Hack's or Joe Horn's command)
  \>> @ Okay even with "hidden" variables (if no directories are hidden)

  @ The original directory name is not itself deleted; instead,
  @ all of its variables are purged, making the directory empty,
  @ but leaving a "placeholder" for subsequent restoring;
  @ you may of course purge the empty directory if you wish, and
  @ subsequently store the saved directory object into any other variable.

  @ Empty directory (to be retrieved from wherever previously stored)
  \<< '&' \->TAG DUP RCL @ Recall saved directory from port
    DUP TYPE 15 \=/ { 514 DOERR } IFT @ Directory object?
    PATH SWAP OVER DUP SIZE GET @ Current directory variable
    #62A02h SYSEVAL EVAL PURGE \>> @ SAFESTO is "supported"

  IFTE 2 MENU \>> @ End in VAR menu so you can see when it's done.

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

The next offering from CURSE is an automated ARCHIVE maker, which
looks through your ports to see where you have stored one or more
previous archive backups of user memory; it then replaces the oldest
of these (or the only one) with a new archive, giving it a new number,
so that the relative ages of multiple archives may be determined:

%%HP: T(3);
@ ARCRP - maintains a group of numbered user memory backups in ports.

@ If you have pre-stored one or more user memory backups,
@ in whatever port(s) you want to keep them in, then each
@ invocation of this program replaces the oldest pre-existing
@ archive with a new, higher-numbered user-memory archive.

@ Backups must be named B.0, B.1, ..., B.9, B.10 etc. [using Greek beta]

@ You must pre-store one or more initial backups, either in different
@ ports, or more than one in the same port, etc., as memory permits.
@ E.g. :2: B.0 ARCHIVE, :3: B.1 ARCHIVE, etc. [using Greek beta]

@ Modify the port number list below to specify all ports which
@ should be searched to find existing backups; however, only
@ ports containing existing backups will actually be used
@ to store replacements for existing backup files.

\<< 0 { } { 2 3 4 5 } @ For 512K card in slot 2; EDIT for other card(s).
  1 \<< PVARS DROP + \>> DOLIST
  1 \<< DUP DTAG \->STR DUP "'\Gb." POS
    { 4 OVER SIZE 1 - SUB OBJ\-> SWAP 2 \->LIST }
    { DROP2 } IFTE \>> DOLIST SORT
  DUP DUP SIZE GET SWAP HEAD DUP SIZE GET DUP PURGE
  OBJ\-> SWAP DROP OBJ\-> SWAP HEAD 1 + STD
  "'\Gb." SWAP + OBJ\-> SWAP \->TAG ARCHIVE DROP \>>
@ G/GX only; Checksum #3FADh, 228.5 bytes (on stack)

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

Do you ever want to re-arrange the order of your port variables?

This accomplishes very little, but just to show that it can be done:

%%HP: T(3); @ PORD - Order object(s) in any port (or user memory)
@ If Port 0 or user memory, then object(s) move to front
@ (will not re-order any directories in user variables, however).
@ If Port 1-33, then object(s) move to end.
@ Name all the objects in a port to completely arrange the order.
@ Any libraries are detached before moving; perform OFF/ON to re-attach.
@ All port objects require an equal amount of free temporary memory.
@ G/GX (can be used with S/SX if you have DOLIST and REVLIST programs).

\<< { } + IF DUP SIZE THEN @ argument may be a single name or a list
  1 \<< DUP TYPE 12 \=/ { "-" \->TAG } IFT \>> DOLIST
  DUP 1 GET \->STR ":1" < { REVLIST } IFT @ User / Port 0  vs. Ports 1-33
  1 \<< DUP OBJ\->
    SWAP DUP TYPE { DROP } { PATH SWAP HOME DETACH EVAL } IFTE
    SWAP DUP RCL ROT { "0" "1" } SWAP POS { NEWOB } IFT
    SWAP DUP PURGE STO \>> DOLIST ELSE DROP END \>>
@ Checksum #D4E3h, 239.5 bytes (on stack)

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

Do you want to know how much memory is used for each object in
either port memory or user memory?  The BYTES command does not
handle this for port objects, and it also has a bug with VAR objects:

%%HP: T(3); @ BY - Extended BYTES command (length only, no checksum).
@ Gives number of bytes for object on stack, or for named stored object.
@ Corrects an HP48 bug in BYTES for built-in commands stored in variables.
@ Accepts port-tagged names, gives bytes used in port (exc. ROM library).
@ For other tagged objects (except names), gives size of stack object.
@ Objects in covered ports require equal free space in tempob.

\<< -55 CF DUP BYTES SWAP DROP SWAP
  { { } @ For other argument types, we use result of BYTES
    6 { { 18 19 } OVER VTYPE POS { \->STR SIZE 8 + SWAP } IFT } @ 'name'
    12 { DUP IFERR VTYPE THEN DROP ELSE @ :tag:obj  vs. :port:name
        OVER RCL BYTES SWAP DROP ROT ROT 16 == @ Library vs. Backup obj.
        { DROP } { OBJ\-> DROP \->STR SIZE + 10 + } IFTE SWAP END }
  } DUP2 SWAP TYPE POS 1 + GET EVAL DROP \>> @ Dispatch on argument type

@ If you already have a BY command in Hack (or other) library,
@ then choose a different name for this program.

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

Miscellaneous:

Sum of bytes used for a list of variables (including port variables):

\<< IF DUP SIZE THEN 1 'BY' DOLIST END 0 + 0 + \GSLIST \>>
@ E.g. 2 PVARS SWAP [this program] + should result in 131072 [128K]
@ (and similarly for every 128K RAM card port).

List of individual bytes used for a list of variables:

\<< IF DUP SIZE THEN 1 \<< DUP BY 2 \->LIST \>> DOLIST END \>>
@ Then optionally press EVAL to separate the answers on the stack.

Change the name 'BY' if you used a different name for that program.

A quick list of all installed auto-attaching libraries:

\<< PATH HOME LIBS SWAP EVAL 1
  \<< DUP TYPE 2 == { 1 5 SUB } IFT \>> DOLIST \>>
@ Then invoke your favorite list viewer to review the results,
@ which is each library name followed by its library number and port
@ (in ascending library number sequence).

Review all your port contents:

\<< { a list of port numbers } 1 \<< PVARS + \>> DOLIST \>>
@ Then use your favorite viewer, or press EVAL to separate the results;
@ each port lists all variables, and then free bytes or "ROM" (read-only).

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

Well, that's enough of a CURSE for one day, I suppose.

Have a healthy and prosperous New Year,
including the prosperity of gaining knowledge,
both of the world around us and the consciousness within us.

"The world extends on either side, no wider than the heart is wide;
 above the Earth is stretched the sky, no higher than the soul is high."
          - Edna St. Vincent Millay

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