*M*      TFILE    TO ENTER A FILE NAME IN THE FILE OF TEMPORARY FILES
         DEF      TFILE:            PATCHING DEF
TFILE:   RES
MONPROC  SET      1
         SYSTEM   UTS
*
         SPACE    3
*P*      NAME:    TFILE
*P*      PURPOSE: TO ENTER THE NAME OF A FILE IN THE FILE
*P*               OF TEMPOR ARY FILES FOR THE CURRENT USER.
*P*               WHEN THE USER GOES TO ACCTSUM AT LOGOFF
*P*               TIME, THE FILES INDICATED WILL BE RELEASED.
*P*      METHOD:  THE FPT OF THE TFILE CAL IS USED AS AN FPT
*P*               FOR A WRITE CAL ON THE USER'S *T FILE, THUS
*P*               A KEY IS ENTERED WITH NO DATA.
*P*      REFERENCE: BATCH PROCESSING REFERENCE MANUAL 90 17 64.
         SPACE    3
         REF      J:BASE            SCRATCH STORAGE IN JIT
         REF      Y002              BIT 10
         REF      CLSSEG            CLOSE MONITOR OVERLAY
         REF      X0                NO BITS
         REF      MSRRDWT           READ/WRITE ENTRY IN IORT
         REF      J:JIT             JOB INFORMATION TABLE
         REF      J:STAR            POINTERS TO USERS ID FILES IN JIT
         REF      OPNSEG            OPEN MONITOR OVERLAY
         REF      ACCN              OFFSET TO LOGON ACCOUNT IN JIT
         REF      PULLEXIT          STACK RETURN
*                 SYMBOLIC REGISTER DEFINITIONS.
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         SPACE    3
*                 DECLARE TEMP FILE NAME
         DEF      MSRTFILE          MODULE ENTRY POINT
*D*      NAME:    TFILE
*D*      REGISTERS: NORMAL CAL STANDARDS
*D*      PURPOSE: TO ENTER THE NAME OF A FILE IN THE FILE
*D*               OF TEMPOR ARY FILES FOR THE CURRENT USER.
*D*               WHEN THE USER GOES TO ACCTSUM AT LOGOFF
*D*               TIME, THE FILES INDICATED WILL BE RELEASED.
*D*      METHOD:  THE FPT OF THE TFILE CAL IS USED AS AN FPT
*D*               FOR A WRITE CAL ON THE USER'S *T FILE, THUS
*D*               A KEY IS ENTERED WITH NO DATA.
*D*      REFERENCE: BATCH PROCESSING REFERENCE MANUAL 90 17 64.
         SPACE    3
MSRTFILE PUSH     SR4
         LW,SR1   J:BASE
         PUSH     SR1
         PUSH     R7
         LI,R7    X'E0000'          RESET
         AND,R7   FPARAM,R6          FPARAM
         STW,R7   FPARAM,R6           RESIDUE
         LW,R7    Y002
         CW,R7    FCD,R6
         BAZ      1A1
*                 CLOSE DCB WITH DEFAULT.
         LI,R7    X0
         LI,SR1   X'15'
         OVERLAY  CLSSEG,0
*                 OPEN DCB WITH OPTIONS:
*                   FILE,KEYED,UPDATE,DIRECT,NAME,ACCT,KEYM
1A1      RES      0
         LI,SR1   X'14'
         LW,R3    *TSTACK           FPT LOC
         LC       *R3               PRESENCE BITS
         LI,R4    4                 INDEX & COUNTER
         BCS,4    1C5               ABN EXISTS
1C3      LI,R1    X'1FFFF'
         AND,R1   *R4,R6            USE DCB ENTRY
         B        1C1
1C5      LW,R1    2,R3              ASSUME ERR EXISTS
         BCS,8    %+2               IT DOES
1C2      LW,R1    1,R3
         BGEZ     1C1               NOT INDIRECT
         CI,R1    X'1FFF0'          CHK FOR REG
         BANZ     1C4               IT'S NOT
         LW,R2    TSTACK            GET J:BASE
         LW,R2    -1,R2
         LW,R1    *R2,R1            INDIRECT THRU REG
         B        1C1
1C4      LW,R1    0,R1              NORMAL INDIRECT
1C1      STW,R1   D3-4,R4           SET D2 & D3
         CI,R4    3
         BE       1C0               DONE
         BDR,R4   %+1
         BCS,8    1C2               USE FPT
         B        1C3               USE DCB
1C0      RES      0
         LW,D1    MSKOP1
         LW,R7    TSTACK
         LCI      3
         PSM,D1   TSTACK
         AI,R7    1
         LCI      8
         LM,D1    TMPOPN
         LI,4     X'FFFF'
         AND,R4   J:JIT
         SLS,R4   8
         OR,R2    R4
         PUSH     8,D1
         LCI      2
         LM,R1    J:JIT+ACCN
         LM,R3    NOSN              TO RESET ALL
         PUSH     4,R1               SERIAL NUMBERS
STAR     SET      1
         DO       STAR=1
         LW,SR2   J:STAR+4          CHK *T IN JIT
         BNEZ     OPNIT
         ELSE
         LI,SR2   2
         B        OPNIT
         FIN
TRYOUT   LI,R1    2
         STW,R1   5,R7
OPNIT    EQU      %
         OVERLAY  OPNSEG,0
         DO       STAR=1
         ELSE
         AI,SR3   0
         BE       %+2
         BDR,SR2  TRYOUT
         FIN
         BUMP     -15,R1
         PULL     R7
         PULL     SR2
         STW,SR2  J:BASE
         PULL     SR2
         AI,SR3   0
         BNE      *SR2
         LI,SR1   X'11'
         AI,R7 -1    *** ADJUST R7=PLIST-1 HOPE OK RETURNING THRU TFX1
         BAL,SR4  MSRRDWT
         PUSH     SR2
         LI,SR1   X'15'
          PUSH    SR3
         LD,D1    CLSSAV
         PSW,D1   TSTACK
         LW,R7    TSTACK
         PSW,D2   TSTACK
         OVERLAY  CLSSEG,0
         BUMP     -2,R1
         PULL     SR3
         DESTRUCT PULLEXIT
         BOUND    8
CLSSAV   DATA     X'80000000',2
*                 KEYED,DIRECT,UPDATE,SAVE,KMAX
TMPOPN   DATA     2,2,4,2,31
         DATA     X'1000101'
         DATA     X'30000E3'
         DATA     X'2000202'
NOSN     DATA     X'7000000',X'8010000'
MSKOP1   DATA     X'C7480001'
         END
