HPlogo EDIT/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 EDIT/3000 ADVANCED COMMANDS

PROCEDURE

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

4-31. PROCEDURE COMMAND

4-32. PURPOSE

The PROCEDURE command calls and executes a procedure written previously in SPL/3000 (Systems Programming Language for the HP 3000 Computer System), FORTRAN/3000, or any other language which accepts parameters as specified and which produces a logical result and is stored in an MPE/3000 Segmented Library (SL). See the MPE Segmenter Subsystem Reference Manual for a description of SLs.

4-33. FORM

The form of the PROCEDURE command is

   P[ROCEDURE] [pname [G

                       ,P [,rangelist] ]

                        S ]

   

where

pname

is the name (or entry point) assigned to the procedure in the SL.

G, P, S

specify which SL library is to be searched for the procedure. G specifies the group library; P the public library; and S the system library. See the MPE Segmenter Subsystem Reference Manual for a discussion of the group, public, and system libraries. Default for the SL library is S.

rangelist

is the same as that described for basic EDIT/3000 commands in Section III except that a procedure can affect only lines of the WORK file, even if rangelist includes a position or character string. The default for the rangelist is the line at which the cursor is currently positioned in the WORK file.

4-34. DESCRIPTION

The PROCEDURE command with no parameters specified will call the last loaded procedure, with the line at which the cursor is currently positioned.

For EDIT/3000 to be able to call a procedure, certain conventions must be followed when the procedure is written. The procedure must be logical. The order and type of the parameters used in the procedure are as shown in the following SPL/3000 and FORTRAN/3000 examples;

A sample header for an SPL/3000 logical procedure:

   LOGICAL PROCEDURE SAMPLE (STRING, LENGTH, NUMBER, SPACE);

   BYTE ARRAY STRING, NUMBER;

   INTEGER LENGTH;

   ARRAY SPACE;

   

A sample header for a FORTRAN/3000 logical function:

   LOGICAL FUNCTION SAMPLE (STRING, LENGTH, NUMBER, SPACE)

   INTEGER LENGTH, SPACE(20)

   CHARACTER STRING*80, NUMBER*8

   

The procedure must be written to conform to the following requirements:

  1. Be a type logical procedure (if written in SPL/3000) or a type logical function (if written in FORTRAN/3000).

  2. Include these four parameters, in the order shown: STRING, LENGTH, NUMBER, SPACE

    where

    STRING

    is a byte array (in SPL/3000) or a character array (in FORTRAN/3000) that contains one line of the WORK file each time EDIT/3000 calls the procedure. (The line will be within the range specified in rangelist. Maximum size allowed is 255 bytes.)

    LENGTH

    is an integer value specifying the length of the current line being passed by STRING.

    NUMBER

    is a byte array (in SPL/3000) or a character array (in FORTRAN/3000) that contains the line number of the current line being passed by string. Maximum size is 8 bytes.

    SPACE

    is a scratch array of 20 words maintained by EDIT/3000 for the procedure's use.

    SPACE is initialized to null characters (binary zeros) when EDIT/3000 is first entered; there- after, the SPACE array is not initialized for each call of the specified procedure as it iterates through the rangelist of the PROCEDURE command. Consequently, this array may be used to "remember" information in successive calls to the procedure within the rangelist specified.

    These four parameters must be declared by the procedure whether they are used or not.

  3. The procedure must correct the parameter LENGTH if it shortens or lengthens the line in STRING and pass this value back to EDIT/3000. If LENGTH is negative, the line is deleted.

  4. The procedure must return logical TRUE for each successful execution; EDIT/3000 then calls the procedure again for the next line in rangelist.

  5. The procedure must return logical FALSE for an unsuccessful operation. EDIT/3000 then displays a "soft" error message and discontinues further calls to the procedure. Any lines in rangelist not yet processed by the procedure remain as they were before the PROCEDURE command was used.

4-35. Limitations.

A PROCEDURE command can call only logical procedures written in a language which accepts parameters as specified and which produces a logical result.

The procedure must reside in a segmented library.

In addition to the array SPACE, the procedure called by the PROCEDURE command may access the array USERSPACE, as described for the User Interface Procedures (see paragraph 6-1). USERSPACE is a 10 word array which contains the PROCEDURE command's input and output MPE file numbers in the first two words. In order to access this array, the procedure must use the array SPACE indexed from -10 to -1.

4-36. EXAMPLES

A FORTRAN/3000 logical function (stored on disc under the name EDITPROC) to find lines containing ASCII blanks is shown below. The function is compiled using the MPE/3000 :FORTRAN command.

See the MPE Commands Reference Manual for a discussion of the :FORTRAN command.

   : FORTRAN EDITPROC

   

   PAGE 0001     HP32102A.01.4

   

   

   00001000  $CONTROL USLINIT,SEGMENT=SEG1

   00002000        LOGICAL FUNCTION FINDBLANKLINE(STRING,LENGTH,NUMBER,

   00003000        #SPACE)

   00004000        CHARACTER*255 STRING,MESSAGE*28,NMBER*8

   00005000        INTEGER SPACE(20),LMESSAGE(14)

   00006000        EQUIVALENCE (LMESSAGE,MESSAGE)

   00007000        IF(LENGTH.EQ.0)GOTO 20

   00008000        DO 10 I=1,LENGTH

   00009000        IF(STRING[I:1].NE." ")GOTO 30

   00010000        CONTINUE

   00011000        MESSAGE=" LINE NUMBER       BLANK

   00012000        MESSAGE[14:8]=NUMBER

   00013000        CALL PRINT(LMESSAGE,\-28\,\0\)

   00014000        FINDBLANKLINE=.FALSE.

   00015000        RETURN

   00016000        FINDFBLANKLINE=.TRUE.

   00017000        RETURN

   00018000        END

   

   

   ****  NO ERRORS, NO WARNINGS;  PROGRAM UNIT COMPILED  ****

   COMPILATION TIME  0.950 SECONDS  ELAPSED TIME  87.075 SECONDS

   TOTAL COMPILATION TIME 0:00:02

   TOTAL ELAPSED TIME     0:01:41

   

    END OF COMPILE

   

Once the function has been compiled into a User Subprogram Library (USL, see the MPE Segmenter Subsystem Reference Manual), the Segmenter subsystem is accessed with the MPE/3000 :SEGMENTER command as shown below.

The Segmenter command -BUILDSL is used to create an SL file named SL, with 300 records maximum and one disc extent.

The -USL command is used to identify the USL file ($OLDPASS) which contains the function procedure to be added to the SL file.

The segment name containing the procedure (SEG1--see the first statement of the FORTRAN/3000 function) is added to the SL file using the -ADDSL command.

The -LISTSL command shows the segment added and the name of entry points in this segment (FINDBLANKLINE is the only entry point--or procedure name--in this segment). Note that the SL file name contains PUB, meaning that the public account library will have to be searched for this procedure. The -EXIT command terminates Segmenter operation.

   : SEGMENTER

   

   SEGMENTER SUBSYSTEM (C.0)

   -BUILDSL SL,300,1

   -USL $OLDPASS

   -ADDSL SEG1

   -LISTSL

   

   SL FILE SL.PUB.GOODWIN

   

   SEGMENT  0 SEG1           LENGTH   120

   

       ENTRY POINTS   CHECK CAL STT  ADR

       FINDBLANKLINE    3    C    1     0

   

       EXTERNALS      CHECK STT SEG

       BLALNKFILL'      3     4   ?

       CCHRLPB'         0     3   ?

       PRINT            3     2   ?

   

   1

   

   USED                 1600          AVAILABLE         111200

   -EXIT

   

    END OF SUBSYSTEM

   

Once EDIT/3000 is accessed using the MPE/3000 :EDITOR command, the TEXT file is copied into the WORK file with the T[EXT] EDIT3 command and listed with the L[IST] ALL command.

   

   /S SHORT;T EDIT3;L ALL

       1     1-2.   WHAT IS EDIT/3000?

       2

       3     EDIT/3000 is A SUBSYSTEM OF THE HP 3000

       4     MULTIPROGRAMMING EXECUTIVE 0PERATING SYSTEM

       5     (MPE/3000) THAT IS USED TO CREATE AND

       6     MANIPULATE ASCII FILES.

       7

       8     CHARACTERS, STRINGS OF CHARACTERS, OR ENTIRE

       9     LINES OF CHARACTERS CAN BE INSERTED, DELETED,

      10     REPLACED, MODIFIED, SEARCHED FOR, AND OTHERWISE

      11     MANIPULATED BY USING EDIT/3000 COMMANDS.

      12

      13     1-2.  EDIT/3000 FEATURES

      14

      15     WITH EDIT/3000, IT IS POSSIBLE TO

      16

      17     CREATE AND BUILD A NEXT FILE (CALLED A WORK FILE)

      18     BY ENTERING COMMANDS AND LINES OF TEXT FROM THE

      19     STANDARD INPUT DEVICE OR FROM A SPECIAL DISC FILE

      20     CALLED THE HOLD FILE.

      21

      22     SAVE THE WORK FILE INTO A PERMANENT FILE CALLED

      23     THE TEXT FILE.

      24

      25     CALL THE TEXT FILE BACK INTO THE WORK FILE FOR

      26     FURTHER ADDITIONS AND/OR EDITING.

      27

      28     CHANGE ALL OCCURENCES OF A CHARACTER STRING WITH

      29     ONE COMMAND.

      30

      31     DELETE CHARACTERS AND LINES FROM THE WORK FILE.

   

The WHILE block uses the procedure FINDBLANKLINE to locate and delete blank lines as follows:

  1. The FINDQ * command locates the current line in the WORK file.

  2. The command PROCEDURE FINDBLANKLINE,P,* calls the procedure FINDBLANKLINE from the public library (P) to determine if the current line is blank.

  3. If the current line is blank, the procedure returns logical FALSE and EDIT/3000 displays the message

            * 19* FALSE RETURN FROM EDITOR PROCEDURE AT DEPTH 3
    

    The OR command sets the flag to true and the DELETEQ * command deletes the current line from the WORK file. The message

            NUMBER OF LINES DELETED = 1
    

    is displayed.

  4. If the current line is not blank, the procedure returns logical TRUE, the OR command and the command following it (DELETEQ *) are skipped, and the line is not deleted.

  5. Once the last line of the WORK file is reached, the FINDQ * command continues to locate this line until the number of iterations specified in the SET TIME = limit is reached (default limit is 50 iterations).

  6. The LIST ALL command verifies that the lines have been deleted.

   /FINDQ FIRST

   /WHILE

   /   FINDQ *

   /   BEGIN

   /      PROCEDURE FINDBLANKLINE,P,*

   /      OR

   /      DELETEQ *

   /      END

    LINE NUMBER    2     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER    7     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   12     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   14     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   16     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   21     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   24     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   27     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

    LINE NUMBER   30     BLANK

   *19*FALSE RETURN FROM EDITOR PROCEDURE

   AT DEPTH 3

   NUMBER OF LINES DELETED = 1

   *53*L

   TIME-OUT ON WHILE ITERATION

   /LIST ALL

       1     1-2.  WHAT IS EDIT/3000?

       3     EDIT/3000 IS A SUBSYSTEM OF THE HP 3000

       4     MULTIPROGRAMMING EXECUTIVE OPERATING SYSTEM

       5     (MPE/3000) THAT IS USED TO CREATE AND

       6     MANIPULATE ASCII FILES.

       8     CHARACTERS, STRINGS OF CHARACTERS, OR ENTIRE

       9     LINES OF CHARACTERS CAN BE INSERTED, DELETED,

      10     REPLACED, MODIFIED, SEARCHED FOR, AND OTHERWISE

      11     MANIPULATED BY USING EDIT/3000 COMMANDS.

      13     1-2.  EDIT/3000 FEATURES

      15     WITH EDIT/3000, IT IS POSSIBLE TO

      17     CREATE AND BUILD A NEW FILE (CALLED A WORK FILE)

      18     BY ENTERING COMMANDS AND LINES OF TEXT FROM THE

      19     STANDARD INPUT DEVICE OR FROM A SPECIAL DISC FILE

      20     CALLED THE HOLD FILE.

      22     SAVE THE WORK FILE INTO A PERMANENT FILE CALLED

      23     THE TEXT FILE

      25     CALL THE TEXT FILE BACK INTO THE WORK FILE FOR

      26     FURTHER ADDITIONS AND/OR EDITING.

      28     CHANGE ALL OCCURENCES OF A CHARACTER STRING WITH

      29     ONE COMMAND.

      31     DELETE CHARACTERS AND LINES FROM THE WORK FILE.

   /E

   CLEAR? Y

   

    END OF SUBSYSTEM

   
Feedback to webmaster