         SYSTEM   SIG7FDP
         SYSTEM   BPM
*
*        LASTKEY  GET MONITOR KEY AND ACTUAL RECORD SIZE OF LAST
*                 PROCESSED RECORD IN A FILE
*
*      USER SYNTAX:
*        ENTER    LASTKEY  FILE-NAME, DATA-NAME-1, DATA-NAME-2,
*                          |DATA-NAME-3|
*
*                 LASTKEY: THE ENTRY POINT IN THE RUN-TIME ROUTINE
*               FILE-NAME: THE APPROPRIATE FD NAME
*             DATA-NAME-1: THE AREA INTO WHICH THE MONITOR KEY OF THE
*                          LAST RECORD READ OR WRITTEN WILL BE INSERTED
*                          (DISPLAY)
*             DATA-NAME-2: THE AREA INTO WHICH THE LENGTH OF THE MONITOR
*                          KEY WILL BE INSERTED (COMPUTATIONAL)
*                          THIS VALUE WILL BE ZERO IF NO KEY WAS FOUND
*             DATA-NAME-3: THE AREA INTO WHICH THE ACTURAL SIZE, IN
*                          BYTES, OF THE LAST RECORD READ OR WRITTEN
*                          WILL BE INSERTED (COMPUTATIONAL)
*                          THIS PARAMETER IS OPTIONAL
*
*        AUTHER   YOW-YUAN ROBERT LIN            MAY, 1970
*
         REF      C:ABA                                                 LASTKEY
         DEF      LASTKEY
         OPEN     ENTER,LDSAVE,NOKEY,SAVE,RETURN
LASTKEY  LCI      9
         STM,14   SAVE
         STW,15   RETURN            SAVE RETURN ADDR
         AWM,14   RETURN            UPDATE RETURN ADDR
         CI,14    3                                                     LASTKEY
         BGE      %+4                                                   LASTKEY
         LI,2     X'9A'                                                 LASTKEY
         STB,2    10                                                    LASTKEY
         B        C:ABA                                                 LASTKEY
         LI,5     X'1FFFF'          MASK FOR DCB ADDR
         AND,5    *15               R5 = DCB ADDR
         LI,2     0                 CLEAR
         LI,6     0                 CLEAR
         LW,3     4,5               4TH WORD OF DCB TO R3
         SLD,2    15                R2 = RECORD SIZE
         LW,4     5,5               LOAD 5TH WORD
         AND,4    L(X'00000020')    TEST ORG = 2  (KEYED)
         AI,4     0
         BEZ      NOKEY             TO NOT A KEYED FILE
         LW,4     *5                LOAD 1ST WORD TO TEST FCD
         AND,4    L(X'00200000')    TEST CLOSE FILE
         BEZ      NOKEY-1
         LI,4     X'1FFFF'          MASK FOR KBUF
         AND,4    10,5              R4 = LASTKEY ADDR
         AI,4     0                 TEST KEY
         BEZ      NOKEY             IF R4 = 0 BRANCH TO NOKEY
         SLS,4    2                 R4 = BYTE ADDR
         LB,6     0,4               R6 = KEY LENGTH
         AI,4     1                 R4 = ACTUAL KEY ADDR
         AI,15    1                 POINT TO DATA-NAME1
         LI,5     X'7FFFF'          MASK FOR KEY ADDR
         AND,5    *15               R5 = DATA-NAME1
         STB,6    5                 BYTE COUNT FOR MBS
         MBS,4    0                 MOVE KEY TO DATA-NAME1
         AI,15    1                 POINT TO DATA-NAME2
ENTER    LW,5     *15               R5 = ADDR OF KEY LENGTH
         STW,6    *5                STORE KEY LENGTH TO DATA-NAME2
         AI,14    -3                TEST DATA-NAME3
         BLEZ     LDSAVE            NO DATA-NAME3 TO RETURN
         AI,15    1                 POINT TO DATA-NAME3
         LW,5     *15               R5 =ADDR OF ARS
         STW,2    *5                STORE RECORD SIZE TO DATA-NAME3
LDSAVE   LCI      9
         LM,14    SAVE
         B        *RETURN
         LI,2     0                 CLEAR REC SIZE
NOKEY    AI,15    2                 POINT TO DATA-NAME2
         LI,6     0                 NO KEY WAS FOUND
         B        ENTER
SAVE     RES      9
RETURN   RES      1
         CLOSE    ENTER,LDSAVE,NOKEY,SAVE,RETURN
         END
