Jump to page titleUNITED STATES
hp.com home products and services support and drivers solutions how to buy
» contact hp

:

more options
 

hp.com home
End of Jump to page title
Example-PLI How To Perform A File SORT
Jump to content



» 

business support center

Home & Home Office Support:
» HP branded products
» Presario branded products
» Services & Warranties
Small & Medium Business Support:
» Small & Medium Business products
» Small & Medium Business services
Support for IT Professionals:
» Enterprise products (IT Resource Center)
» NonStop enterprise products
» Business & IT Services
Content starts here
Copyright (c) Digital Equipment Corporation 1988. All rights reserved
LAYERED PRODUCT or COMPONENT: PLI V3.1     OP/SYS: VMS V5.0

SOURCE:     Digital Customer Support Center



OVERVIEW:

This program demonstrates how to do a file SORT in PLI.


CAUTION:  This sample program has been tested using:
          PRODUCT: PLI V3.1 on OPERATING SYSTEM: VMS V5.0

However, we cannot guarantee its effectiveness because of the
possibility of errors in transmitting or implementing it.  It is meant
to be used as a template for writing your own program, and it may
require modification for use on your system.


PROGRAM SAMPLE:

SRTR:    PROCEDURE OPTIONS (MAIN);
/*This program demonstrates how to do a file SORT in PLI.*/


/*Include the declaration of the SORT procedures required for a sort
  using the file interface */

%INCLUDE SOR$PASS_FILES;
%INCLUDE SOR$BEGIN_SORT;
%INCLUDE SOR$SORT_MERGE;
%INCLUDE SOR$END_SORT;
%INCLUDE SOR$STAT;
%INCLUDE $STSDEF;

dcl DSC$K_DTYPE_T globalref fixed bin(31) value;

dcl     EOF BIT (1);
        EOF = '0'B;

dcl     LONGEST_RECORD          FIXED BINARY (15) INIT (40);
dcl     KEYFIELD                FIXED BINARY (7);
dcl     RET_LEN                 FIXED BINARY (15);



DECLARE 1  RECIN,   /* REC LEN = 40 */
            3  BADGE        CHAR (06),      /* KEY TO SORT ON */
            3  FILL1        CHAR (05),
            3  NAME         CHAR (16),
            3  FILL2        CHAR (06),
            3  TEAM         CHAR (07);

/* Declare the key buffer area required to sort the file      */
/* An array of fixed binary(15) could be used instead of the  */
/* structure                                                  */
DCL 1 KEY_BUFFER,
      2 number_of_keys      fixed binary(15) init(1),
      2 key_type            fixed binary(15) init(DSC$K_DTYPE_T),
      2 key_order           fixed binary(15) init(0),
      2 start_pos           fixed binary(15) init(1),
      2 key_length          fixed binary(15) init(5);

dcl sortedi file input stream;
DCL sorted char(6) init('sorted');
DCL infile char(11) init('SRT_TST.DAT');

DCL CNTR  FIXED BINARY (31) INIT(0);
dcl (FAB$C_VAR, FAB$C_REL) globalref fixed binary(31) value;

dcl record_type fixed binary(7);
dcl file_org fixed binary(7);

on endfile (sortedi)
    eof = ('1'b);

record_type = FAB$C_VAR;
file_org = FAB$C_REL;

/* Call the sort routines, after each call, check the return status*/

/* SOR$PASS_FILES specifies the input and output file specifications.
   These can be logical names */
STS$VALUE = SOR$PASS_FILES(INFILE,SORTED,RECORD_TYPE);
If ^STS$SUCCESS then goto ERROR;

/*SOR$BEGIN_SORT specifies the sizes of the records, key data types,
  sort sequences and so forth */
STS$VALUE = SOR$BEGIN_SORT (KEY_BUFFER, LONGEST_RECORD);
IF ^STS$SUCCESS THEN goto ERROR;

/*SOR$SORT_MERGE initiates the sorting */
STS$VALUE = SOR$SORT_MERGE();
IF ^STS$SUCCESS THEN goto ERROR;

/*SOR$END_SORT calls SORT to clean up its work areas and close its
  temporary files */
STS$VALUE = SOR$END_SORT();
IF ^STS$SUCCESS THEN goto ERROR;

goto NOERROR;
ERROR:
    put skip(2) edit('SORT failed, ERROR code:',sts$value)
                       (a,x,f(8));
NOERROR:
    put skip edit('END OF PROCESSING')(a);
END;




buy online or call 1.800.AT.COMPAQ
privacy statementusing this site means you accept its terms