HP 3000 Manuals

6-5. EXAMPLES [ EDIT/3000:Reference Manual ] MPE/iX 5.0 Documentation


EDIT/3000:Reference Manual

6-5.  EXAMPLES 

Three user written SPL/3000 procedures, which satisfy the requirements
described above, are shown here.  They are each compiled into a User
Subprogram Library named USERUSL by using the MPE/3000 SPL command.  (See
the MPE Commands Reference Manual for a discussion of the SPL command.)

                         :SPL INIT,USERUSL

                         PAGE 0001    HP32100A.06.05 [4W] (C) HEWLETT-PACKARD COMPANY 1976

                         00001000   00000   0 $CONTROL SUBPROGRAM
                         00002000   00000   0 $CONTROL SEGMENT=INIT'SEG
                         00003000   00000   0 BEGIN
                         00004000   00000   1 LOGICAL PROCEDURE HP32201'USFRINIT(STRING,LEN,
                                              USERSPACE,PROCSPACE);
                         00005000   00000   1 BYTE ARRAY STRING;
                         00006000   00000   1 INTEGER LEN;
                         00007000   00000   1 ARRAY USERSPACE;
                         00008000   00000   1 ARRAY PROCSPACE;
                         00009000   00000   1
                         00010000   00000   1 BEGIN
                         00011000   00000   2  MOVE STRING:=";Q#USERINIT 1.0#; Q#/S SHORT#; 5 SHORT;";
                         00012000   00032   2  LEN:=39;
                         00013000   00034   2  STRING(LEN):=%15;  < <CR> >
                         00014000   00037   2  HP32201'USERINIT:=TRUE;
                         00015000   00041   2 END;
                         00016000   00000   1 END.
                           PRIMARY DB STORAGE=%000;     SECONDARY DB STORAGE=%00000
                           NO. ERRORS=0000;             NO. WARNINGS=0000
                           PROCESSOR TIME=0:00:00;      ELAPSED TIME=0:00:17

     :SPL COMMAND, USERUSL

     PAGE 0001   HP32100A.06.05 [4W] (C) HEWLETT-PACKARD COMPANY 1976

     00001000  00000  0   $CONTROL SUBPROGRAM
     00002000  00000  0   $CONTROL SEGMENT=COMMAND'SEG
     00003000  00000  0   BEGIN
     00004000  00000  1
     00005000  00000  1   LOGICAL PROCEDURE HP32201'USERCOMMAND(STRING,L
                          EN,USERSPACE,PROCSPACE);
     00006000  00000  1   BYTE ARRAY STRING;
     00007000  00000  1   INTEGER LEN;
     00008000  00000  1   ARRAY USERSPACE;
     00009000  00000  1   ARRAY PROCSPACE;
     00010000  00000  1   BEGIN
     00011000  00000  2   LOGICAL POINTER WORDPTR;
     00012000  00000  2   LOGICAL ARRAY L(0:10);
     00013000  00000  2   BYTE ARRAY B(*)=L;
     00014000  00000  2   INTRINSIC PRINT,FWRITE;
     00015000  00000  2
     00016000  00000  2   HP32201'USERCOMMAND:=TRUE;
     00017000  00011  2   MOVE B:="USERCOMMAND ENTERED!";
     00018000  00031  2   FWRITE(USERSPACE(1),L,-20,0):
     00019000  00037  2   @WORDPTR:=@STRING&LSR(1);
     00020000  00042  2   PRINT(WORDPTR,-LEN,0);
     00021000  00046  2   < <
     00022000  00046  2   < <    IMPLEMENT THE COMMAND "QUIT"
     00023000  00046  2   < <    CHANGE "QUIT" TO "KEEP" AND INSERT ";END" AT THE END
     00024000  00046  2   < <    OF THE STRING
     00025000  00046  2   > >
     00026000  00046  2   IF STRING="QUIT" THEN
     00027000  00057  2   BEGIN
     00028000  00057  3     MOVE STRING:="KEEP";
     00029000  00067  3     MOVE STRING(LEN):=";END";
     00030000  00100  3     STRING(LEN:=LEN+4):=13;  < <CR> >
     00031000  00107  3   END;
     00032000  00107  2   END;
     00033000  00000  1   END.
      PRIMARY DB STORAGE=%000;    SECONDARY DB STORAGE=%00000
      NO. ERRORS=0000;            NO. WARNINGS=0000
      PROCESSOR TIME=0:00:01;     ELAPSED TIME=0:00:26

     :SPL ADD,USERUSL

     PAGE 0001   HP32100A.06.05 [4W] (C) HEWLETT-PACKARD COMPANY 1976

     00001100  00000  0   $CONTROL SUBPROGRAM
     00002000  00000  0   $CONTROL SEGMENT=ADD'SEG
     00003000  00000  0   BEGIN
     00004000  00000  1   LOGICAL PROCEDURE HP32201'USERADD(STRING,LEN,U
                          SERSPACE,PROCSPACE);
     00005000  00000  1   BYTE ARRAY STRING;
     00006000  00000  1   INTEGER LEN;
     00007000  00000  1   ARRAY USERSPACE;
     00008000  00000  1   ARRAY PROCSPACE;
     00009000  00000  1   BEGIN
     00010000  00000  2   LOGICAL POINTER WORDPRT;
     00011000  00000  2   LOGICAL ARRAY L(0:10);
     00012000  00000  2   BYTE ARRAY B(*)=L;
     00013000  00000  2   BYTE ARRAY SPACES(0:9);
     00014000  00000  2   BYTE ARRAY INPUT(0:255);
     00015000  00000  2   BYTE POINTER SRC'PTR;
     00016000  00000  2   BYTE POINTER DFST'PTR;
     00017000  00000  2   DEFINE TAB'CHAP="*";
     00018000  00000  2   DEFINE INDENTATION=10-((@DEST'PTR-@STRING) MOD 10)#;
     00019000  00000  2   EQUATE CARRIAGE'RETURN=13;
     00020000  00000  2   INTRINSIC PRINT,FWRITE;
     00021000  00000  2
     00022000  00000  2   HP32201'USERADD:=TRUE;
     00023000  00021  2   MOVE B:="USERADD ENTERED!";
     00024000  00037  2   FWRITE(USERSPACE(1),L-16,0);
     00025000  00045  2   @WORDPTR:=@STRING&LSB(1);
     00026000  00050  2   PRINT(WORDPTR,-LEN,0);
     00027000  00054  2   <<
     00028000  00054  2   <<   SEARCH FOR *'S--WHEN FOUND, INSERT SPACES
     00029000  00054  2   <<   THE TEXT IS "TABBED" OVER TO THE NEXT COLUMN THAT IS
     00030000  00054  2   <<   A MULTIPLE OF TEN
     00031000  00054  2   >>
     00032000  00054  2    MOVE INPUT:=STRING,(LEN);
     00033000  00060  2    INPUT(LEN):=CARRIAGE'RETURN;
     00034000  00063  2    MOVE SPACES:="            ";
     00035000  00076  2
     00036000  00076  2    TOS:=@STRING;
     00037000  00077  2    TOS:=@INPUT;
     00038000  00100  2
     00039000  00100  2   TAB:
     00040000  00100  2    MOVE *:=* WHILE AN,0;
     00041000  00101  2    @SRC'PTR:=TOS;
     00042000  00102  2    @DEST'PTR:=TOS;
     00043000  00103  2
     00044000  00103  2    IF SRC/PTR=TAB'CHAR THEN
     00045000  00106  2    BEGIN
     00046000  00106  3      MOVE DEST'PTR:=SPACES,(INDENTATION),2;
     00047000  00117  3      LEN:=LEN+INDENTATION-1;
     00048000  00127  3      TOS:=@SRC'PTR+1;
     00049000  00131  3      GO TO TAB;
     00050000  00132  3    END;
     00051000  00132  2
     00052000  00132  2    IF SCR'PTR=CARRIAGE'RETURN THEN RETURN;
     00053000  00136  2
     00054000  00136  2    DEST'PTR:=SCR'PTR;
     00055000  00140  2    TOS:=@DEST'PTR+1;
     00056000  00142  2    TOS:=@SRC'PTR+1;
     00057000  00144  2    GO TO TAB;
     00058000  00145  2   END;
     00059000  00000  1   END.
      PRIMARY DB STORAGE=%0000;    SECONDARY DB STORAGE=%00000
      NO. ERRORS=0000;             NO. WARNINGS=0000
      PROCESSOR TIME=0:00:01;      ELAPSED TIME=0:00:16

Next, the Segmenter subsystem is accessed with the MPE/3000 SEGMENTER
command.  The USL Segmenter command is used to identify the USL file
(USERUSL) which contains the function procedures to be added to the SL
file, and the BUILDSL command is used to create an SL file with 20
records maximum and one disc extent.  The segment containing each
procedure is added to the SL file using the ADDSL command, and by
specifying the segment name for each procedure (see the $CONTROL SEGMENT=
statement at the beginning of each SPL/3000 procedure listed above).  The
LISTSL command shows the segments added and the names of entry points for
each segment (in this case, there is only one entry point for each).
Assuming we are logged-on in the PUB group of the SCC account, note that
the SL file name is SL.PUB.SCC, so that the segmented library of the PUB
group in the SCC account will have to be searched for these procedures.
EXIT is typed to terminate Segmenter operation.  (See the MPE Segmenter
Reference Manual for a more detailed explanation of the Segmenter and
segmented libraries).

Note that if the procedures are to be installed in the system SL, all
three procedures should be put in the same segment, if possible, rather
than in separate segments - as was done here.  This saves space in the
CST (Code Segment Table), which is shared by everyone on the system and
keeps track of the segments in the system SL.

                 :SEGMENTER
                 HP32050A.00.00 SEGMENTFR/3000 (C) HFWLETT-PACKARD CO. 1979
                 -USL USERUSL
                 -BUILDSL SL,20,1
                 -ADDSL INIT'SEG
                 -ADDSL COMMAND'SEG
                 -ADDSL ADD'SEG
                 -LISTSL

                 SL FILE SL.PUB.SCC

                 SEGMENT   0 INIT'SEG          LENGTH     44

                    ENTRY POINTS      CHECK CAL STT ADR
                    HP32201'USERINI     0    C   1     0

                    EXTERNALS         CHECK STT SFC

                 100

                 SEGMENT   2 COMMAND'SEG       LENGTH     114

                    ENTRY POINTS      CHECK CAL STT ADR
                    HP32201'USERCOM     0     C    1      0

                    EXTERNALS         CHECK STT SFC
                    PRINT               0      3   ?
                    FWRITE              0      2   ?

                 010

                 SEGMENT   2 ADD'SEG           LENGTH     154

                    ENTRY POINTS      CHECK CAL STT   ADR
                    HP32201'USERADD     0     C    2      0

                    EXTERNALS         CHECK STT SEG
                    PRINT               0      3   ?
                    FWRITE              0      2   ?

                 001

                 USED                   3000           AVAILABLE               2000

                 -EXIT

                 END OF SUBSYSTEM

EDIT/3000 is invoked using the MPE RUN command.  The PARM=16 parameter is
used since the segmented libraries need to be searched.  The USERINIT
procedure is called, which prints out "USERINIT 1.0" and "/S SHORT" and
executes the EDIT/3000 command S [ET] SHORT. Since this procedure returns
TRUE (see the listing above), both of the other two procedures will be
invoked.

The T[EXT] AFILE command (in response to EDIT/3000's slash prompt)
causes the USERCOMMAND procedure to be called, since it is called
whenever a command line has been entered.  The USERCOMMAND procedure
print"USERCOMMAND ENTERED!" and repeats the command line.

When the ADD command is used and a line of text is entered, the USERADD
procedure is called which prints out "USERADD ENTERED!" and repeats the
line.  The line is accepted since USERADD returns the value TRUE (see the
listing above).  When AFILE is listed, we see that USERADD has also
interpreted each asterisk (*) in a line of text as a tab.

The QUIT command is interpreted by the USERCOMMAND procedure as the
standard EDIT/3000 commands K[EEP] ;END. In this case, the filename is
defaulted; note that it is printed out below the command.  (The QUIT
command also allows for a filename to be specified if desired; see the
listing of the USERCOMMAND procedure.)

                   :RUN EDITOR.PUB.SYS;PARM=16

                   HP32201A.7.04 EDIT/3000 WED, JAN 17, 1979,  2:03 PM
                   (C) HEWLETT-PACKARD CO. 1978
                   USERINIT 1.0
                   /S SHORT
                   /T AFILE
                   USERCOMMAND ENTERED!
                   T AFILE
                   /LIST ALL
                   USERCOMMAND ENTERED!
                   LIST ALL
                        1       THIS IS LINE ONE.
                        2       THIS IS LINE TWO.
                   /ADD
                   USERCOMMAND ENTERED!
                   ADD
                        3       *COLUMN TEN, LINE THREE.
                   USERADD  ENTERED.
                   *COLUMN TEN,LINE THREE.
                        4       ARC*123
                   USERADD  ENTERTED!
                   ABC*123
                        5       //
                   ...
                   ;/LIST ALL
                   USERCOMMAND ENTERED!
                   LIST ALL
                        1       THIS IS  LINE ONE.
                        2       THIS IS  LINE TWO.
                        3                  COLUMN TEN,LINE THREE.
                        4       ABC        123
                   /OUIT
                   USERCOMMAND ENTERED!
                   QUIT
                   AFILE
                   PURGE OLD?Y

                   END OF PROGRAM


MPE/iX 5.0 Documentation