Finally closing the loop with this thread: 
With offline help from Rob, the following are two slightly different means 
to accomplish the same thing - answering my original question about how to 
sort a file within XEDIT without performing disk I/O, and without 
needlessly buffering the whole file twice in XEDIT, and not even 
mentioning avoidance of the XEDIT command "INSERT" (which truncates very 
long records based on the maximum command line input).

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

/* PIPXESRT XEDIT - CMS Pipelines sort in XEDIT w/o disk I/O        */
/*                  No Pipelines Runtime Library (RTL) reliance     */
   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/ALT/'     /* Current settings  */
   $alt.1=alt.1
   $alt.2=alt.2

  'COMMAND SET MSGMODE OFF'                    /* Many line deletes */
  'COMMAND SET AUTOSAVE OFF'                   /* Many line deletes */
  'COMMAND TOP'
   address command,
     'PIPE (END ?)' ,
        '| XEDIT',           /* Read recs from XEDIT ring file      */
        '| SORT' sortargs ,  /* Sort and pass XEDIT input recs      */
        '| o: FANOUT' ,      /* Copy sorted recs to XEDIT ring file */
        '| TAKE FIRST 1' ,   /* Do not buffer full file             */
        '| SPECS /:0 DELETE */' ,
        '| SUBCOM XEDIT' ,   /* Execute ":0 DELETE *" command       */
        '? o:' ,             /* Accept sorted records from FANOUT   */
          '| XEDIT'          /* Write sorted recs to XEDIT ring file*/
   src=rc

  'COMMAND SET ALT' $alt.1 $alt.2             /* Prevent AUTOSAVE   */
  'COMMAND SET AUTOSAVE' autosave.1           /* Restore setting    */
  'COMMAND TOP'                               /* Back to first line */
  'COMMAND SET MSGMODE' msgmode.1             /* Restore setting    */
Exit src


The following is a nearly-identical version, but which requires the 
Pipelines RunTime Library "CONDITIONAL" keyword on the STRLITERAL stage 
(see: PIPELINE NEWS1111), and also provides an example of the "IF" stage. 
The "IF" stage _is_ present in the distributed CMS Pipelines, just not 
documented there - perhaps because it was never fully tested?


/* RTLXESRT XEDIT - CMS Pipelines sort in XEDIT w/o disk I/O        */
/*                  Prereq: Pipelines Runtime Library (RTL) "COND"  */
   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/ALT/LRECL/'  /* Curr settings  */
   $alt.1=alt.1
   $alt.2=alt.2

  'COMMAND SET MSGMODE OFF'                    /* Many line deletes */
  'COMMAND SET AUTOSAVE OFF'                   /* Many line deletes */
  'COMMAND TOP'
   address command,
     'PIPE (END ?)' ,
        '| XEDIT',           /* Read recs from XEDIT ring file      */
        '| SORT' sortargs ,  /* Sort and pass XEDIT input recs      */
        '| STRLITERAL PREFACE CONDITIONAL /:0 DELETE */' , /*Preface*/
        '| PAD' lrecl.1 ,    /* Force cmd to match file lrecl       */
        '| x: IF TAKE' ,     /* "IF" recs (yes: ":0 DELETE *" + recs*/
        '| SUBCOM XEDIT' ,   /* "THEN" execute ":0 DELETE *" cmd    */
        '| x:' ,             /* "ELSE"                              */
        '| XEDIT' ,          /* Write sorted recs to XEDIT ring file*/
        '| x:'               /* "ENDIF"                             */
   src=rc

  'COMMAND SET ALT' $alt.1 $alt.2             /* Prevent AUTOSAVE   */
  'COMMAND SET AUTOSAVE' autosave.1           /* Restore setting    */
  'COMMAND TOP'                               /* Back to first line */
  'COMMAND SET MSGMODE' msgmode.1             /* Restore setting    */
Exit src


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