The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

HP49G+. How to erase a directory that contains lots of stuff?
Message #1 Posted by J.C.Boco on 14 Dec 2007, 7:59 p.m.

I have 2 HP49G+ calculators....one for use and one for "backup" (for exams). You know, just in case one of the keys breaks or something (hasn't happened after 3 years of tough use, but still...)

anyway, I periodically say all my stuff onto an SD card, and then use the SD card in HP #2 and use the RESTORE command to bring #2 up to date.

Well, now I get a message when I try to RESTORE "insufficient memory". So I just cleared a bunch of variables, then cleared some more, then cleared some more. CLUSR isn't too convenient, because I have lists of variables and folders with stuff in them (all mixed up together), and the CLUSR always stops when it comes to a full directory and says something like "I can't do that".

And NOW I have even MORE stuff on the SD card from my last ARCHIVE command. It will take even MORE manual erasing of stuff until there is enough memory on HP#2 for me to do a RESTORE command.

Is there a way to purge a Directory, even if the directory has gobs of stuff in it? I figure all I have to do is purge just one directory (Thermo or Fluids or Statics), any folder with big hunky equations will do. Then I can just do the RESTORE thing.

Any ideas?

      
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #2 Posted by Raymond Del Tondo on 14 Dec 2007, 8:22 p.m.,
in response to message #1 by J.C.Boco

Use TVARS with your wanted var type(s) as argument, then PURGE.

HTH

Raymond

      
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #3 Posted by James M. Prange (Michigan) on 15 Dec 2007, 4:28 p.m.,
in response to message #1 by J.C.Boco

Quote:
Is there a way to purge a Directory, even if the directory has gobs of stuff in it? I figure all I have to do is purge just one directory (Thermo or Fluids or Statics), any folder with big hunky equations will do. Then I can just do the RESTORE thing.

Any ideas?


Of course, to do a RESTORE, you do have to have enough free memory to put the backup object on the stack first.

As you've noted, CLUSR (synonym for CLVAR) and, for that matter, PURGE won't purge non-empty subdirectories.

To purge non-empty subdirectories (including any "descendent" subdirectories), you can use the PGDIR command. PGDIR, depending on the structure of the subdirectory, can be rather slow, as it "crawls" the branch into the lowest subdirectories, and after all subdirectories at that level have been emptied, moves up the path to the next higher directory and does the same thing, until it's finished purging the target subdirectory.

Note that both PURGE and PGDIR can take either a name or a list of names for their argument.

A program to purge everything (except the hidden subdirectory) would be:

%%HP: T(3)A(D)F(.);
\<<
  HOME          @ Make home directory current.
  15 TVARS      @ Get the list of subdirectories.
  PGDIR         @ Purge the subdirectories (empty or not).
  CLVAR         @ Purge everything else.
 \>>
But if you intend to do a RESTORE, it may be faster to clear all memory first. RESTORE starts out by doing what amounts to a PGDIR on the home directory, so will purge all variables (and subdirectories).

To clear all user memory more quickly, hold down the ON key while pressing the A and F keys, then release first the F key, and then the A and ON keys. This gets you to the TTRM (Try To Recovery Memory?) display. If you respond YES, then it will check for memory corruption and recover as much as it can (which may take a lot of time), and if you respond NO, then it will clear all user memory.

A possible disadvantage to clearing all memory is that all modes will be restored to their default states. For the modes that are controlled by flags, you can have a list of flags (retrieved by the RCLF command) included in a variable within the archive and, after doing a RESTORE, restore the flags with the STOF command. But some modes aren't controlled by flags, and those you'd have to take care of yourself.

For the 49 series, the PUSH command will store the current path and flags lists in the reserved variable ENVSTACK (in the CASDIR subdirectory), which would be included in an archive, and the POP command will retrieve the most recent path and flags list and restore them.

Note that the RESTORE ends with a warmstart, which clears flag -62 (forcing USER keyboard mode off), but doesn't affect any other mode.

Regards,
James

Edited: 15 Dec 2007, 6:56 p.m. after one or more responses were posted

            
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #4 Posted by James M. Prange (Michigan) on 15 Dec 2007, 6:03 p.m.,
in response to message #3 by James M. Prange (Michigan)

PS:

On the 49 series, the filer's PURGE operation will purge non-empty directories. It's like a combination of PURGE and PGDIR.

Regards,
James

                  
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #5 Posted by James M. Prange (Michigan) on 15 Dec 2007, 7:25 p.m.,
in response to message #4 by James M. Prange (Michigan)

PPS:

Of course, for a program that purges everything (including non-empty subdirectories) in just the current directory and any subdirectories, but leaves parent directories in place, you could use:

%%HP: T(3)A(D)F(.);
\<<
  15 TVARS      @ Get the list of subdirectories.
  PGDIR         @ Purge the subdirectories (empty or not).
  CLVAR         @ Purge everything else.
 \>>
For a program that takes either a global name or list of global names, and purges subdirectories (empty or not) as well as other variable types, try the following:
%%HP: T(3)A(D)F(.);
\<<
  DUP               @ Copy the argument.
  IF
    TYPE 6. ==      @ Global name?
  THEN
    1. \->LIST      @ Put the name into a list.
  END
  1. OVER SIZE      @ For each element of the list...
  FOR n
    DUP             @ Copy the list.
    n GET           @ Get the name.
    DUP             @ Copy the name.
    IF
      VTYPE 15 ==   @ Subdirectory?
    THEN
      PGDIR         @ Purge the subdirectory.
    ELSE
      PURGE         @ Purge any other type of variable.
    END
  NEXT
  DROP              @ Discard the list.
\>>
Regards,
James
                        
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #6 Posted by John Keith on 16 Dec 2007, 9:50 a.m.,
in response to message #5 by James M. Prange (Michigan)

Hi James,


I was inspired by your post to look up the Type command in the AUR, and the type number (15) that you use for subdirectories is not listed, and neither is 13. Where else might I find this information, and what (if anything) is type 13??

                              
Re: HP49G+. How to erase a directory that contains lots of stuff?
Message #7 Posted by James M. Prange (Michigan) on 16 Dec 2007, 8:43 p.m.,
in response to message #6 by John Keith

Quote:
I was inspired by your post to look up the Type command in the AUR, and the type number (15) that you use for subdirectories is not listed, and neither is 13.
Well, to verify that a subdirectory really is type 15, I simply put a subdirectory on the stack and used it as the argument for the TYPE command, without bothering to look it up in any reference material.

I probably should've written "directory object", as the home directory and subdirectories use the same prologue and are both user type 15, the differences being in the object bodies.

Yes, the 48gII/49g+ AUR seems to have left out types 13 and 15; I have no idea why.

Quote:
Where else might I find this information,
The 49G AUG lists object types 0-31.

Type 31 should be "External object", not "Extended object".

The 48G series AUR lists types 0-31, but in the 48 series, 27-31 are all "External object".

Quote:
and what (if anything) is type 13??
Type 13 is a unit object.

Regards,
James

Edited: 17 Dec 2007, 12:30 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall