From: flavio@cflav.sublink.org (Flavio Casetta)
Newsgroups: comp.sys.hp48
Subject: Re: Sorting With SmartROM
Date: 9 Jan 93 19:15:45 GMT
Organization: Flavio Casetta, Reg'd HP ISV & OEM of handheld computers.

akcs.ejf@hpcvbbs.cv.hp.com (Ed Fasula) writes:

> I want to sort a stack of lists by the first object.  How does one do
> this with SmartROM?  I looked into the hidden commands and there was
> refrence to sortn, sortIDONTREMEMBER, anyway only sortany and sort
> show-up in the index.  

sortany goes for you (the name should tell you something...)

Let's create a program sorting the list on the first element.

It will take as input a stack like this:

N+1:  list1
N  :  list2
...:  ...
2  :  listN
1  :  N        real counter

and will rearrange the lists according to the order of their first element.
The program will check that the n objects are actually on the stack and they 
are lists before going on with the sorting process. If any of these conditions
is violated it issues an error. The program saves correctly the LASTARG 
arguments and is provided with argument checking as well stack integrity 
capabilities so that you haven't to worry about crashes.
It works even if the stack contains merely a 0 (a null meta object).

Type in the following :

821 189 ->Xlib      CKOBJ          checks if the elements are all of the same
                                   type
#62266h ->EXT       DUP#0=         True if there are no list
#61993h ->EXT       case           if True then do next and exit
#18DBFh ->EXT       UNCOERCE       gets back the 0
#032C2h ->EXT       Over
#62216h ->EXT       TYPELIST?      checks if they are lists
#63B46h ->EXT       NcaseTYPEERR   if not Bad Argument Type error
#06E97h ->EXT       '              pushes the following program as argument for
                                   sortany
  #05089h ->EXT       CARCOMP      extracts the first element (1)
  #03223h ->EXT       Swap
  #05089h ->EXT       CARCOMP      extracts the first element (2)
  #03223h ->EXT       Swap
  #06E97h ->EXT       '            pushes the following command on the stack
  #1EC5Dh ->EXT       >            compares (1) > (2) ?
  #18F23h ->EXT       EvalNoCK     EVALuates > without affecting LASTARG
  #2A7CFh ->EXT       %0<>         translates into system boolean
  8 ->PRG                          collects the subprogram

821 110 ->Xlib      sortany        calls the generic sort algorithm
#18DBFh ->EXT       UNCOERCE       converts the counter from sysbin to real
11 ->PRG                           collects the program

'SORTLIST1' [STO]

the checksum is #5B77h

now you can sort any set of lists whose first elements are comparable with >.

> Where are these other commands and what do they
> do.  

sortany is a hidden command, therefore it is described in the hidden commands
reference manual.

> I also got a whole bunch of programs with SmartROM (on disk) and I
> don't know what 90% of them do.  This package is confusing!  

As usual you don't tell us the name of the programs.
How can I tell you what they do if you don't tell me the name ?

The SmartROM may be confusing. Since it is not toy but a very complex 
application development platform, I can understand you are confused.

Simple software is seldom powerful.

Bye

Flavio


__
* flavio@cflav.sublink.org (Flavio Casetta)
 ---------------------------------------------------------------------
| The usual disclaimer does not apply      |   +59 440404 (Vox populi) |
| ForCALC's opinions are necessarily mine  |   +59 304490 (Fax dei)    |
Newsgroups: comp.sys.hp48