hp 50g sort order in Filer



#2

I was sure that I had seen the Filer sort my dir entries in dir-name-sorted followed by filename-sorted when I pressed the Order key. But now I cannot get this to work. Is there a method for doing this?

What I am looking for:
[DIR a]
[DIR b] etc.
followed by (for example}
{} list A
"" text B

I have the regular soft key options available, but not a 1-button sort as above.

Rich


#3

I don't know if the filer has an option for this kind of sorting. Meanwhile try this:

<< VARS SORT ORDER 15 TVARS ORDER
>>

Gerson.

#4

After you've chosen a port or directory from the "tree" view, press NXT twice to get SORT as the last menu item on that page; TYPE is the closest to what you want. I think that even then, within each type, objects are sorted according to their "storage order" rather than alphabetically.

You can use some "keyboard shortcuts" within the filer too. Instead of choosing the sort option from a choosebox you can press:

  • T or RightShift T for Type
  • LeftShift T for inverse Type
  • Rightshift N for Name
  • LeftShift N for inverse Name
  • S or RightShift S for Size
  • LeftShift S for inverse Size
  • I don't know of a shortcut to get back to "Original" or "Unsorted".
Personally, I prefer Wolfgang's Filer6, available at http://page.mi.fu-berlin.de/~raut/WR49/index.htm#General.

Regards,
James


Edited: 26 Nov 2006, 4:01 p.m.


#5

PS:

Within the Filer, pressing unshifted N does EVAL, which is on the same key, which is the reason for requiring the RightShift N for sorting by name.

Regards,
James

#6

Thanks for the code. I tried it, and it works fine for me. If there are no dirs in the list, then it errors, but that's OK because it has already sorted the files.

This code appears to work (I'm new to programming this class of calculator) because all the entries, irrespective of type, are sorted in the first pass; then the second specifies only dir-type entries and those are ORDERed, bubbling the non-dir-types to the bottom of the list, but still sorted.

My references do not show a type 15 for dir types.

I tried Filer6, and I can see that it is more powerful than the builtin Files command, but is will not do what I want. I am likely to use it to manage my SD card, however, as it appears to do what the builtin program will not do.

Thanks to both for your help.
Rich


#7

Ah, I was thinking that you wanted the display of objects sorted in the filer. Note that if you want to make it permanent, the filer also has the ORDER operation.

But for permanent sorting, Gerson's program seems better. If you care to avoid the possible error, then change it to:

%%HP: T(3);
\<<
VARS SORT ORDER
15 TVARS DUP
IF
SIZE
THEN
ORDER
ELSE
DROP
END
\>>

Regards,
James

Edited: 26 Nov 2006, 8:40 p.m.


#8

Hello James,

Thanks for the improvement! I will use it from now on. I had noticed the error Rich mentioned but then I didn't care about it because I use this mostly to keep my HOME directory sorted that way, and there's always other directories therein. I once wrote a program that avoided the double sorting, but I can't find it anymore. I remember it was much longer. Anyway, the 50G is so fast this is not a problem.

Regards,

Gerson.


#9

Hello Gerson,

You're welcome, of course.

A possible disadvantage is that often I don't really want a
directory stored in ASCII order. For example, I usually keep
reserved variables and "special" variables such as a list of flags
that I want easily accessible at the end of the directory.

Note that the 28 series and 48SX/S don't have a built-in SORT
command, so for those models a sorting program would have to be
called or a sorting routine substituted for SORT.

Also note that these programs can take a long time to execute.
Neither VARS nor TVARS is particularly fast, and ORDER can take a
long time if a lot of variables have to be moved.

To avoid an error if used on an empty directory, we could use:

%%HP: T(3);
@ Download to 49 series in exact mode.
@ Results from the BYTES command:
@ 48G series:
@ Checksum: # B9F0h
@ Size: 76
@ 49 series:
@ Checksum: # 991Bh
@ Size: 72.
\<< @ Begin program.
VARS @ Get list of variables.
DUP @ Copy of variables list.
IF
SIZE @ Variables list not empty?
THEN
SORT @ Sort list to ASCII order.
ORDER @ Reorder variables.
15 TVARS @ Get list of subdirectories.
DUP @ Copy of subdirectories list.
IF
SIZE @ Subdirectories list not empty?
THEN
ORDER @ Move subdirectories to front.
ELSE
DROP @ Discard empty subdirectory list.
END
ELSE
DROP @ Discard empty variables list.
END
\>>
But one wouldn't be likely to want to use such a program on an
empty directory anyway, so why bother? Well, I did so as a step in
developing a recursive sorted order program that will work on the
current directory and any subdirectories (which may happen to be
empty):
%%HP: T(3);
@ Download to 49 series in exact mode.
@ Recursive program; change ProgName within program to whatever
@ name is chosen for storing the program.
@ Results from the BYTES command:
@ 48G series:
@ Checksum: # 5394h
@ Size: 129
@ 49 series:
@ Checksum: # C209h
@ Size: 125.
\<< @ Begin program.
VARS @ Get list of variables.
DUP @ Copy of variables list.
IF @
SIZE @ Variables list not empty?
THEN
SORT @ Sort list to ASCII order.
ORDER @ Reorder variables.
15 TVARS @ Get list of subdirectories.
DUP @ Copy of subdirectories list
SIZE @ Number of subdirectories.
IF @
DUP @ Subdirectories list not empty?
THEN @
OVER @ Copy of subdirectory list.
ORDER @ Move subdirectories to front.
1 @ Loop begin index.
SWAP @ Move down number of subdirectories.
FOR n @ For each subdirectory.
DUP @ Copy of subdirectory list.
n GET @ Get subdirectory name.
EVAL @ Make subdirectory current.
ProgName @ Call this program recursively.
UPDIR @ Return to parent directory.
NEXT @
DROP @ Discard subdirectories list.
ELSE @
DROP2 @ Discard empty subdirectories list and size 0.
END @
ELSE @
DROP @ Discard empty variables list.
END
\>> @ End program.
Or one could use a subprogram stored in a local variable which
calls itself recursively. In this case, the program can be stored
with any global name without changing the name within the program.
Note that a "compiled local name" is used because I use the name
in the subprogram before the local variable actually exists.
%%HP: T(3);
@ Download to 49 series in exact mode.
@ Results from the BYTES command:
@ 48G series:
@ Checksum: # A5A5h
@ Size: 159
@ 49 series:
@ Checksum: # 5367h
@ Size: 155.
\<< @ Begin program.
\<< @ Begin recursive subprogram.
VARS @ Get list of variables.
DUP @ Copy of variables list.
IF @
SIZE @ Variables list not empty?
THEN
SORT @ Sort list to ASCII order.
ORDER @ Reorder variables.
15 TVARS @ Get list of subdirectories.
DUP @ Copy of subdirectories list.
SIZE @ Number of subdirectories.
IF @
DUP @ Subdirectories list not empty?
THEN @
OVER @ Copy of subdirectory list.
ORDER @ Move subdirectories to front.
1 @ Loop begin index.
SWAP @ Move down number of subdirectories.
FOR n @ For each subdirectory.
DUP @ Copy of subdirectory list.
n GET @ Get subdirectory name.
EVAL @ Make subdirectory current.
\<-s @ Put this recursive subprogram on stack.
EVAL @ Execute recursive subprogram.
UPDIR @ Return to parent directory.
NEXT @
DROP @ Discard subdirectories list.
ELSE @
DROP2 @ Discard empty subdirectories list and size 0.
END @
ELSE @
DROP @ Discard empty variables list.
END @
\>> @ End recursive subprogram.
\-> \<-s @ Bind recursive subprogram.
\<< @ Begin defining procedure
\<-s @ Put recursive subprogram on stack.
EVAL @ Execute recursive subprogram.
\>> @ End defining procedure.
\>> @ End program.

Other, perhaps better, programs could be made, for example perhaps
using the DOLIST command.

Oh, by the way, for the Classic RPN aficionados who feel that
putting the loop index numbers before the FOR itself is overdoing
the postfix notation, the above recursive programs demonstrate the
reason.

Regards,
James


#10

Why don't you put this as an article?

-- Antonio

#11

Quote:
Ah, I was thinking that you wanted the display of objects sorted in the filer. Note that if you want to make it permanent, the filer also has the ORDER operation.

I could have lived with the display, I suppose. Although I can see an additional benefit to having the directory sorted so that the VAR key gives me predictable results. But in any event, I couldn't get any keystroke combination in either the builtin or Filer6 to give me the results I wanted. Thanks to your input, though, I tried this...

%%HP: T(3)A(R)F(.);
\<<
VARS SORT ORDER
15 TVARS
IFERR
ORDER
THEN
DROP
END
\>>

...and it seems to work just fine.

Rich


#12

Yes, that should work; just two different approaches to dealing with the possibility of an empty list. Assuming that last arguments saves are enabled, LASTARG may give different results.

Regards,
James


Possibly Related Threads...
Thread Author Replies Views Last Post
  3rd order ODE diff eq Richard Berler 0 748 10-23-2013, 09:53 PM
Last Post: Richard Berler
  Rearanging the "Fixed" sort order of Prime's Apps icons Joe Horn 3 1,237 10-02-2013, 10:24 AM
Last Post: Han
  HP 10S+ order on DeRekenwinkel.nl Mic 2 955 12-06-2012, 04:44 AM
Last Post: Klaas Kuperus
  DM-15CC family is available to order Jeff Johnson 35 6,320 07-07-2012, 05:20 AM
Last Post: Pascal
  Order HP39GII in Europe Timo 4 1,406 03-14-2012, 02:11 AM
Last Post: Cyrille de Brébisson
  35s - find roots of 3rd and higher order equations Chris C 11 2,553 02-25-2012, 02:55 PM
Last Post: Thomas Klemm
  For those in UK: 15C LE available for pre-order at Sleath's Bart (UK) 10 2,373 01-06-2012, 07:26 PM
Last Post: Paul Brogger
  The best way to order a 15C LE in German Timo 3 1,034 12-16-2011, 02:07 PM
Last Post: jose gonzalez divasson
  Another order of 15c LE for me! jonathan G harris 2 817 09-27-2011, 03:18 AM
Last Post: Thomas Radtke
  Rationale for 15C L.R. result order? Mike Fikes 9 1,907 09-20-2011, 05:59 PM
Last Post: Crawl

Forum Jump: