HP 3000 Manuals

Sort from a Pascal Program [ MPE XL Native Language Programmer's Guide ] MPE/iX 5.0 Documentation


MPE XL Native Language Programmer's Guide

Sort from a Pascal Program 

This program shows how to sort an input file (formal designator INPF) to
an output file (formal designator OUTF) using the SORTINIT intrinsic
call.

      1   $USLINIT$
      2   $STANDARD_LEVEL 'HP3000'$
      3
      4   PROGRAM example (inpf,outf);
      5
      6   TYPE
      7      smallint  = -32768 .. 32767;
      8
      9      sort_rec  = RECORD
     10                    position:  smallint;
     11                    length:    smallint;
     12                    seq_type:  smallint;
     13                  END;
     14
     15      char_seq  = RECORD
     16                    array_code:smallint;
     17                    language:  smallint;
     18                  END;
     19
     20      file_arr  = RECORD
     21                    num_file:  smallint;
     22                    num_zero:  smallint;
     23                  END;
     24
     25      file_rec  = PACKED ARRAY [1..72] of CHAR;
     26
     27      file_num  = FILE of file_rec;
     28
     29   VAR
     30      numkeys: smallint;
     31      reclen:  smallint;
     32      keys:    sort_rec;
     33      cseq:    char_seq;
     34      inp:     file_arr;
     35      out:     file_arr;
     36      inpf:    file_num;
     37      outf:    file_num;
     38
     39   PROCEDURE sortinit;   INTRINSIC;
     40   PROCEDURE sortend;    INTRINSIC;
     41
     42   PROCEDURE main;
     43   BEGIN
     44      numkeys := 1;
     45      reclen  :=72;
     46

     47      WITH keys DO
     48      BEGIN
     49        position := 1;
     50        length   := 4;
     51        seq_type := 9;
     52      END;
     53
     54      WITH cseq DO
     55      BEGIN
     56        array_code:=1;
     57        language:= 12;
     58      END;
     59
     60      WITH inp  DO
     61      BEGIN
     62        RESET (inpf);
     63        num_file := FNUM (inpf);
     64        num_zero := 0;
     65      END;
     66
     67      WITH out  DO
     68      BEGIN
     69        REWRITE (outf);
     70        num_file := FNUM (outf);
     71        num_zero := 0;
     72      END;
     73
     74      sortinit (inp,out,,reclen,,numkeys,keys,,,,,,,,cseq);
     75      sortend;
     76
     77   END;
     78
     79   BEGIN
     80      main;
     81   END.

In the example execution, the input and output files are associated with
the terminal ($STDIN and $STDLIST):

     :FILE INPF=$STDIN
     :FILE OUTF=$STDLIST
     :RUN PROGRAM;MAXDATA=12000

     character
     credit
     DEBIT
     :EOD

     credit
     character
     DEBIT

     END OF PROGRAM
     :



MPE/iX 5.0 Documentation