From: jhmeyers@miu.edu (John H Meyers)
Newsgroups: comp.sys.hp48
Subject: Rename any variable or directory
Date: 29 Aug 1998 11:54:22 GMT
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Lines: 67
Message-ID: <6s8q5e$cuh$1@news.iastate.edu>
Reply-To: jhmeyers@miu.edu
NNTP-Posting-Host: vax1.mum.edu
Xref: republic.btigate.com comp.sys.hp48:15205

It is not particularly difficult to rename any user variable:

o Recall it to the stack.
o Purge it from VAR memory.
o Store it under new name (or even in another directory).

This is what the G/GX Memory Browser does, anyway,
when you "move" a variable.

However, whenever you do this, the "brand new" variable
which was just stored is now first in the VAR menu;
perhaps you would rather have left it in the exact
position it had originally occupied.

Perhaps you would also like to have been warned before
clobbering some other variable which also had the same name
(Memory Browser just replaces whatever the old name contained).

Maybe you would even like to be able to rename a directory
(Memory Browser says "Error: Directory Not Allowed")

If you use a "hacking" library, it may contain a REN command,
which does work on directories, and takes care of leaving the
variable where it was; however, if the new name already exists,
the "rename in place" operation still gets carried out,
leaving you with two identically named variables
in the same directory; both names appear in the VAR menu,
but only the first variable's contents can be accessed or stored
into (rename that first variable again to correct the problem).

If you do not have a hacking library, but still want all the
abilities alluded to above, the following program does all:

%%HP: T(3); @ Rename any variable or directory

@ Args:  'new' 'old' (names)
@ (this argument order was chosen to be consistent with existing REN)
@ Will not clobber an existing variable.
@ Preserves existing location of variable in VAR menu.

\<< { OVER VTYPE -1 > { 9 DOERR } IFT @ 'new' already exists?
  DUP RCL DROP } @ 'old' must already exist
  #185C7h SYSEVAL EVAL @ SysRPL: DoHere: (in this directory only)
  VARS DUP2 SWAP POS 1 - 1 SWAP SUB ROT ROT @ list of preceding vars
  DUP RCL SWAP IF DUP VTYPE 15 == THEN PGDIR ELSE PURGE END SWAP STO
  IF DUP SIZE THEN ORDER ELSE DROP END \>> @ restore original order

Notes:

o See XPURGE on Goodies Disk #7 (Utils) for a faster,
  universal PURGE/PGDIR replacement.

o See ORD on Goodies Disk #10 (Utils) for a faster ORDER.

o See "Lightning-fast VARS command" 1997/11/15
  <http://www.dejanews.com/getdoc.xp?AN=289754439>
  for a faster VARS (and an alternate version which you should
  substitute above if you might rename any "hidden" variables)

o See "HIDEVARS - Yes, another hider!" 1997/11/18
  <http://www.dejanews.com/getdoc.xp?AN=290412746>
  for the meaning of "hidden" variables.

o Any incorrect syseval address voids memory contents warranty :)

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