H DEBUG(*YES) *O: CRTBNDRPG *O: DBGVIEW(*ALL) CVTOPT(*DATETIME) *O: DFTACTGRP(*NO) BNDDIR(UTILITY QC2LE) ACTGRP(*NEW) *===================================================================== D/COPY QRPGLECPY,@SORT_P *===================================================================== D Array DS D Elem 10A Dim(10) D NbrElem S 10I 0 Inz D Elem@ S * Inz D String S 10A * C Eval Elem(1) = 'Locate' C Eval Elem(2) = 'Michael' C Eval Elem(3) = 'Apple' C Eval Elem(4) = 'Zenith' C Eval Elem(5) = 'Wherefore' C Eval Elem(6) = 'Bottle' C Eval Elem(7) = 'Michelle' C Eval NbrElem = 7 * * Sort by the entire Elem field in ascending order * C Eval rc = inz_@sort_asc( 1 : 10 ) C Callp(e) qsort( %addr( Array ) : C NbrElem : C %size( Elem ) : C @sort@@ ) * C If %error or C @sort_control.error > 0 C Exsr *PSSR C Endif * * Sort by just the 3rd and 4th characters within Elem * C Eval rc = inz_@sort_asc( 3 : 2 ) C Callp(e) qsort( %addr( Array ) : C NbrElem : C %size( Elem ) : C @sort@@ ) * C If %error or C @sort_control.error > 0 C Exsr *PSSR C Endif * * Search for a duplicate entry * C Eval @sort_control.count = 0 C Eval String = ' ch' C Eval Elem@ = bsearch( %addr( String ) : C %addr( Array ) : C NbrElem : C %size( Elem ) : C @search@@ ) * C If %error or C @sort_control.error > 0 C Exsr *PSSR C Endif * * Sort by the entire Elem field in descending order * C Eval rc = inz_@sort_dsc( 1 : 10 ) C Callp(e) qsort( %addr( Array ) : C NbrElem : C %size( Elem ) : C @sort@@ ) * C If %error or C @sort_control.error > 0 C Exsr *PSSR C Endif * C Return * *===================================================================== * *PSSR Error subroutine *===================================================================== C *PSSR Begsr C Return C Endsr