         PAGE
R0       EQU      0
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
         PAGE
         TITLE    'FILTRAN'
FILTRAN  DSECT    1
         SYSTEM   SIG7
*
* FILTRAN         FILE ID TRANSLATOR
*
* INPUT
*        CMBX     COMMAND BUFFER INDEX OF NEXT ARGUMENT
*        TERM     TERMINATOR OF CURRENT ARGUMENT
* OUTPUT
*        FILE     +0    FIL ID COUNT (1-N,2-N,A,3-N,A,P)
*                 +1    COMMAND BUFFER INDEX OF FILE NAME
*
*
         REF      GETARG,TEXTARG,ERROR
         REF      CMBX,TERM,FILE
         REF      ARGBUF4,#DELIM
         REF      NCHAR
         REF      DEVICE
         REF      DEV%IN,DEV%OUT
         REF      DEV%SAV
*
         USECT    FILTRAN
         LCI      7                 SAVE REGISTERS
         PSM,R5   *R7
*
         LI,R5    1                 INITIALIZE
         LW,R6    CMBX,R7
*
NEXTARG  LI,R1    12
         STW,R1   #DELIM,R7         SET DELIM FLAG FOR FID
         BAL,SR4  GETARG            GET NEXT ARGUMENT
         STCF     SR1
*
         CI,D2    1
         BG       NEXT2             ERROR REPORTED BY GETARG
         LW,R4    R5                SAVE PARAMETER COUNT
         LW,R3    DEVICE,R7
         BNEZ     NEXT4        PCL DEVICE.
         LW,R3    DEV%IN,R7
         CI,D1    1            TEST IF TO
         BE       %+3
         CI,D1    12           OR OVER.
         BNE      %+2          SYSTEM INPUT DEVICE.
         LW,R3    DEV%OUT,R7   SYSTEM OUTPUT DEVICE.
NEXT4    EQU      %
         STW,R3   DEV%SAV,R7   SAVE DEVICE CODE.
         CI,R3    7                 TEST IF ANS TAPE
         BNE      %+2               NO
         AI,R4    6                 SELECT 3RD EDIT TABLE
         LC       SR1
         BCS,1    NEXT1
         LI,R1    ARGBUF4+1         GET INDEX INTO ARGBUFF
         LB,R2    *R7,R1            GET 1ST CHAR OF ARG
         CI,R2    X'E7'             IS IT AN X
         BNE      NEXT1             NO
         AI,R1    1
         LB,R2    *R7,R1            GET 2ND CHAR OF ARG
         CI,R2    X'7D'             IS THIS A HEX STRING
         BNE      NEXT1             NO
         AI,R4    3                 SELECT 2ND EDIT TABLE
         CI,R3    7                 IS DEVICE ANS TAPE
         BNE      NEXT1             NO
         AI,R4    -2                ADJUST TABLE INDEX
NEXT1    LW,R1    EDITCNST-1,R4     EDIT FILE ID PARAMETER
         CI,D1    3                 TEST IF DELETE
         BNE      NEXT3             NO
         CI,R5    1                 FILE NAME
         BNE      NEXT3             NO
         MTW,0    NCHAR,R7
         BEZ      NEXT2             ALLOW NULL NAME
NEXT3    EQU      %
         BAL,SR4  TEXTARG
*
NEXT2    EQU      %
         LW,R1    TERM,R7
         CI,R1    '.'               ACCT NO. OR PASS WORD PRESENT
         BNE      STORE
         LW,R3    DEV%SAV,R7   RESTORE DEVICE CODE.
         CI,R3    7                 IS DEVICE ANS TAPE
         BE       ERR7              YES-ERROR
         CI,R5    3                 CHECK FOR MAXIMUM PARAMETER COUNT
         BE       ERR7
         AI,R5    1                 INCREMENT PARAMETER COUNT
         B        NEXTARG
ERR7     LI,R1    7                 ERROR 07
         BAL,SR4  ERROR
         B        NEXTARG
*
STORE    STW,R5   FILE,R7           STORE PARAMETER COUNT
         STW,R6   FILE+1,R7         STORE CMBX OF FILE NAME
         STW,R0   #DELIM,R7         RESET DELIMITER FLAG
*
RETURN   LCI      7                 RESTORE REGISTERS
         PLM,R5   *R7
         B        *SR4
*
EDITCNST DATA     X'0400011F'       NAME
         DATA     X'05000008'       ACCOUNT
         DATA     X'06000108'       PASSWORD
         DATA     X'04000441'       HEX NAME
         DATA     X'05000413'       HEX ACCT
         DATA     X'06000413'       HEX PASSWORD
         DATA     X'04000111'       ANS NAME
         DATA     X'04000425'       ANS HEX NAME
         END

