A useful HP-50G program to keep the DIRs clean...



#2

Everyone has their personal preferences for organizing their homes, rooms, offices, etc. - even the directories and files on personal computers. I am a neat freak and like things to be highly organized. The way in which the directories and objects on my HP-50G are organized makes it easy for me to locate important things.

I like every directory from HOME on down to be organized like this: alphabetically with directories first and all other objects afterwards.

I like programs to clean up after they are run by making sure that the flags are restored to their pre-run state and I want the VAR menu to always be displayed.

I'm also an automation freak. On my Linux workstations, I have a collection of useful scripts that I wrote that make working with the system very easy. Likewise so for my HP-50G, I have written a series of useful programs that keep things organized the way I like them.

Here is a program I wrote (that resides in HOME) to relist all directories and objects to my liking. I'm posting it here so others may find usefulness with it too...

<<
"Relisting the Directory..." 1. DISP
{} DUP 'xA' STO 'xB' STO
VARS OBJ-> 1. SWAP
START
DUP 1. ->LIST SWAP VTYPE
IF 15. ==
THEN xA + 'xA' STO
ELSE xB + 'xB' STO
END
NEXT
xA SORT xB SORT + ORDER
{xA xB} PURGE 2. MENU
>>
'ReList' STO

I have it in the HOME's CST list, so it can run in any subdirectory and clean up whatever is the "current" directory.

P.S. Nobody is perfect, so I welcome suggestions for improvement.

Edited: 12 Nov 2009, 2:20 p.m.


#3

I use a very similar program on my 48GX. It's actually multiple programs - one of them to do the actual sorting, and one to recursively traverse the whole directory structure.

SORTALL: This is the program that sorts all directories beneath the current directory. It works by stepping through each directory in the current directory, and then running itself from within those directories. After that, it sorts the current directory, and goes back up one level. Run it in HOME to sort everything (except the hidden directory).

<< 0 { } \-> P DIRS
<< 15 TVARS 'DIRS'
STO DIRS SIZE
IF
THEN 1 DIRS
SIZE
FOR P DIRS P
GET EVAL SORTALL
NEXT
END PATH 1 DISP
SORTDIR UPDIR
>>
>>

SORTDIR: This is the program that actually does the sorting. The main version lives in HOME, and sorts into an alphabetical list of directories, followed by programs, followed by everything else. The "everything else" isn't alphabetized, to save time.

<< 8 TVARS DUP
IF SIZE 1 >=
THEN SORT ORDER
ELSE DROP
END 15 TVARS DUP
IF SIZE 1 >=
THEN SORT ORDER
ELSE DROP
END
>>

The reason this is a separate program is because I have a different version of SORTDIR stored in some directories where I want special sorting rules. For example, I have a directory with some custom units, and a CST menu. I hide all the actual unit variables by sorting them after an object with a null name, since CST provides better functionality than VAR does for unit menus, where it's rather easy to accidentally overwrite them. Then I have another directory where I only sort a couple program names to the front, and leave everything else as-is.


#4

Thanks Dave! I have Droid48 on my T-Mobile G1 cell-phone, so I'll add your code to the emulator and see how it works out. :)

#5

Quote:
[...]

<<
"Relisting the Directory..." 1. DISP
{} DUP 'xA' STO 'xB' STO
VARS OBJ-> 1. SWAP
START
DUP 1. ->LIST SWAP VTYPE
IF 15. ==
THEN xA + 'xA' STO
ELSE xB + 'xB' STO
END
NEXT
xA SORT xB SORT + ORDER
{xA xB} PURGE 2. MENU
>>
'ReList' STO

P.S. Nobody is perfect, so I welcome suggestions for improvement.


Bill,

You can replace "xA + 'xA' STO" with "'xA' STO+"

On the non-programming side, here's a trick for sorting things when the sort order isn't alphabetic. Prefix the name with a number. For example, sometimes I need one subdirectory for each month, so I call them 01Jan 02Feb 03Mar etc.

Thanks for sharing this utility.

Dave


#6

You're welcome, Dave - and thanks for improving it! :)


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,511 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  HP41 display clean up Wolfgang 4 903 02-18-2013, 02:13 AM
Last Post: Bruce Larrabee
  Elastic Collisions Program: HP 50g Eddie W. Shore 9 1,754 03-28-2012, 07:58 AM
Last Post: bluesun08
  How a little HP-50g program mutated into an iPhone app Peter Murphy (Livermore) 6 1,378 01-12-2012, 06:06 PM
Last Post: Norman Dziedzic
  Hp 50g finance program peacecalc 0 496 01-01-2012, 10:22 AM
Last Post: peacecalc
  HP 50g trilogy. The new HP 50g Blue (and II) Pablo P (Spain) 18 3,086 09-19-2011, 03:08 AM
Last Post: BruceH
  How should I clean my hp-15c JJDietrich 3 823 12-08-2010, 11:05 AM
Last Post: Martin Pinckney
  How to clean a 20B ? Karl-Ludwig Butte 4 897 12-07-2010, 10:38 AM
Last Post: Martin Pinckney
  How to install/ru​n this program in an Hp 50g. Vasheer 2 724 08-17-2010, 06:34 PM
Last Post: Daniel Oliva
  How to clean the buttons on HP 48G? Denizen 2 738 01-15-2009, 06:12 AM
Last Post: nacho

Forum Jump: