I'd been looking for a clean idiom for sorting a complete file from XEDIT
using Pipeline's much more powerful sort arguments.  I also did not want
to write to disk during that process.

Most of the examples I'd run across were somewhat awkward.  So I wrote the
following and wonder if more-expert plumbers that I would take a look at
it and comment where it might be simplified.  I realize that there are all
sort of bells and whistles that can be added to such a sort function, but
that's a separate discussion from a clean, rather concise example.

Mike Walter
Aon Corporation
The opinions expressed herein are mine alone, not my employer's.

/* PIPXESRT XEDIT - Pipelines sort in XEDIT w/o disk I/O, 20101208 mrw */

   parse source xos xct xfn xft xfm xcmd xenvir .
   parse upper arg parms 1 operands '(' options ')' parmrest

   parse var operands sortargs

  'COMMAND EXTRACT /MSGMODE/AUTOSAVE/'        /* Current settings  */
  'COMMAND SET MSGMODE OFF'                   /* Many line deletes */
  'COMMAND SET AUTOSAVE OFF'                  /* Many line deletes */
  'COMMAND TOP'
   address command,
     'PIPE (END ?)' ,
        '| XEDIT',
        '| sort: FANOUT' ,                    /* Send copy to sort  */
        '| ELASTIC' ,                         /* Prevent stall      */
        '| HOLE' ,                            /* Discard input recs */
        '| APPEND LITERAL :0 DELETE *' ,      /* Cmd: Delete allrecs*/
        '| SUBCOM XEDIT' ,                    /* Execute Cmds       */
        '| HOLE' ,                            /* Discard Cmds, msgs */
        '| sorted: FANIN' ,                   /* Bring back sorted  */
        '| PAD RIGHT 80' ,                    /* Pad appropriately  */
        '| XEDIT' ,                           /* Insert sorted recs */
        '?   sort:' ,
          '| SORT' sortargs ,
          '| sorted:'
  'COMMAND TOP'
  'COMMAND SET MSGMODE' msgmode.1             /* Restore setting    */
  'COMMAND SET AUTOSAVE' autosave.1           /* Restore setting    */
  'COMMAND :1'                                /* Back to first line */
Exit



The information contained in this e-mail and any accompanying documents may 
contain information that is confidential or otherwise protected from 
disclosure. If you are not the intended recipient of this message, or if this 
message has been addressed to you in error, please immediately alert the sender 
by reply e-mail and then delete this message, including any attachments. Any 
dissemination, distribution or other use of the contents of this message by 
anyone other than the intended recipient is strictly prohibited. All messages 
sent to and from this e-mail address may be monitored as permitted by 
applicable law and regulations to ensure compliance with our internal policies 
and to protect our business. E-mails are not secure and cannot be guaranteed to 
be error free as they can be intercepted, amended, lost or destroyed, or 
contain viruses. You are deemed to have accepted these risks if you communicate 
with us by e-mail.

Reply via email to