*
         DEF      ERRMSGE
         CSECT    1
* INITIAL CONDITIONS:
*        R2 = DCB ADDRESS
*        R3 = BUFFER ADDRESS
*        R4 = BUFFER SIZE
*        SR4 = RETURN ADDRESS
*        D1 = KEY IN TEXTC FORMAT
*
* CALLING SEQUENCE:
*        BAL,SR4  ERRMSGE
*
* RESULTS:
*        R1 = KEY IN TEXTC FORMAT
*        R4 = ACTUAL RECORD SIZE
*        OUTPUT MESSAGE IN BUFFER POINTED TO BY R3
*
* ABNORMAL AND ERROR CONDITIONS:
*        R4 = ACTUAL RECORD SIZE
*        EBCDIC EQUIVALENT OF HEX KEY
         PAGE
         SYSTEM SIG7
R2       EQU      2
R3       EQU      3
R4       EQU      4
SR4      EQU      11
D1       EQU      12
*
TELSTACK  EQU   X'9000'           SPECIAL BUFFER SUPPLIED BY TEL.
*
         PAGE
         CSECT    1
OPEN     GEN,1,7,7,17 1,X'14',0,R2  DCB ADDRESS IN R2
         DATA     X'C7480001'
         DATA     ERRADD            ERROR ADDRESS
         DATA     ABNADD            ABNORMAL ADDRESS (OPEN)
         DATA     2                 KEYED FILE
         DATA     2                 DIRRECT ACCESS
         DATA     1                 IN MODE
         DATA     2                 SAVE
         DATA     4                 MAXIMUM KEY SIZE
         DATA     X'01000202'
         TEXTC    'ERRMSG'          FILE NAME
         DATA     X'02010202'
         TEXT     ':SYS    '        ACCOUNT
*
*
READ     GEN,1,7,7,17 1,X'10',0,R2  DCB ADDRESS IN R2
         DATA     X'F8000000'
         DATA     ABNREAD           ERROR ADDRESS READ
         DATA     ABNREAD           ABNORMAL ADDRESS (READ)
         PZE      *R3               BUFFER ADDRESS IN R3
         PZE      *R4               BUFFER SIZE IN R4
         PZE      *R3               KEY ADDRESS IN R3
*
*
CLOSE    GEN,1,7,7,17 1,X'15',0,R2
         DATA     X'80000000'
         DATA     2                 SAVE THE FILE
*
         PAGE
ERRMSGE  EQU      %
         STW,D1   *R3               STORE THE KEY
         CAL1,1   OPEN              OPEN ERROR FILE
         CAL1,1   READ              READ RECORD
         LI,R4    4
         LW,R4    *R2,R4            GET ACTUAL RECORD SIZE
         SLS,R4   -17               RIGHT JUSTIFY VALUE
CLOSFILE CAL1,1   CLOSE             CLOSE ERROR FILE
         B        *SR4              RETURN
*
ABNREAD  EQU      %
         CAL1,1   CLOSE
ERRADD   EQU      %
ABNADD   EQU      %
         LI,R4    0                 INITIALIZE INDEX
GO       AND,D1   =X'00FFFFFF'      MASK TO STRIP BYTE ZERO
         SLS,D1   4                 SHIFT A HALF BYTE
         LB,R2    D1                GET THAT BYTE
         CI,R2    9                 IS THE VALUE > 9
         BG       GREATER           YES: DIFFERENT CONVERSION
         OR,R2    =X'000000F0'      HEX TO EBCDIC CONVERSION
         B        %+3
GREATER  OR,R2    =X'000000C0'      HEX TO EBCDIC CONVERSION
         AI,R2    -9                FINISH CONVERSION
         STB,R2   *R3,R4            STORE THE CONVERTED VALUE
         AI,R4    1
         CI,R4    6
         BL       GO                LOOP CONTROL
DONE     EQU      %                 CONVERSION COMPLETE
         LI,R4    6
         B        *SR4
         DEF       WRITERR1
         DEF      WRITERR
         REF      M:XX
         REF      M:UC
D2       EQU      13
WRITERR  RES      0                 ASSUME  D1 = ERR CODE
         AW,D1   =X'03030000'
WRITERR1 RES      0
         LI,D2    1
         MSP,D2   TELSTACK          BUILD BUF IN TELS STACK
         LW,3     TELSTACK
         LI,D2    35
         MSP,D2   TELSTACK
         LI,4     140               BYTE SIZE
         LI,2     M:XX              DCB
         BAL,11   ERRMSGE
         CAL1,1   WRITEX            WRITE MESSAGE
         LI,D2    -36
         MSP,D2   TELSTACK
         B       *0                 EXIT ON 0
WRITEX   RES      0
         GEN,8,24 X'11',M:UC
         GEN,4,28 3,0
         PZE     *3                 BUFFER
         PZE     *4                 SIZE
         END

