On 2017-06-12 14:29, John Gateley wrote:
Hi

Last weeks discussion on sorting a REXX stem inspired me to write a program to 
do it.

example call to sort ascending
  "ISPEXEC LIBDEF ISPLLIB DATASET ID ('my_loadlib') STACK"
  "ALLOC FI(SORTPRT)  DUMMY"
  r_c = SORTSTEM(my_stem_name,'A')
  "FREE FILE(SORTPRT)"
  "ISPEXEC LIBDEF ISPLLIB "

SORTSTEM gets the variable count from my_stem_name.0 and then looks at every 
variable in the stem to get the maximum length.

Then it getmains some storage big enough for the maximum record plus 4 bytes 
for the length of the variable

It then calls the system SORT passing E15 and E35 exits

  SORT FIELDS=(1,max_len,BI,A),FILSZ=stem_count
  OPTION MSGDDN=SORTPRT
  RECORD TYPE=F,LENGTH=(max_len+4)

On each call to the E15 exit the next stem variable is read, padded with spaces 
and the length put on the end

On each call to the E35 exit the variable is put back into the stem, starting 
at 1, using the original length


It will be on File#953 of the CBT Tape soon, but it anyone wants a preview then 
the code is in IEBUPDTE format here
http://www.spurtle.biz/STEMASM.txt
and supporting macros here
http://www.spurtle.biz/STEMMAC.txt
You will need to assemble the six modules then link
     INCLUDE SYSLIB(STEMSORT)
     ENTRY STEMSORT

Will your code handle non-numerical "indices"?

tom = 'dick'
my_stem.tom = 'Harry'

Robert
--
Robert AH Prins
robert.ah.prins(a)gmail.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to