.TITLE GCML .IDENT /M0008/ .ENABL LC ; ; Title: FORTRAN callable version of GCML ; ; Routine Name: GCML ; ; File Name: [377,2]GCML.MAC ; ; Author: M.J.McCombe ; Documentation and mods : B.Hillam ; ; Description: ; This routine allows the FORTRAN programmer to use the ; facilities of the GCML subroutine to get a command line. ; By default, GCML converts any lower case characters found ; in the command line to upper case, but this can be ; overridden by the optional IMODE parameter : see below. ; The command may come from a terminal or from a command ; file, and the source of the command is transparent ; to the calling program : GCML decides where to interrogate ; according to the rules below. ; On entry, the user should have a LUN assigned to the terminal. ; 1) On its first attempt, GCML tries to obtain a command line ; buffer from MCR. If this fails, it prompts the terminal, ; using a user supplied prompt. ; 2) On subsequent calls, GCML continues to prompt the ; terminal until it receives an indirect command filename, ; indicated by @. The default file extension is .CMD. ; 3) Having opened the specified file, GCML retrieves subsequent ; lines from it each time it is called until end-of-file ; is encountered. Further indirect command files may be ; specified in a command file, to a current maximum nesting depth of 3. ; 4) Command lines beginning with ; are usually treated as comment lines ; and are not returned to the calling program. ; Control-Z from the terminal, in response to a prompt, ; gives an error return from GCML. The possible error ; returns are listed below. ; ; Type HELP ADD GCML STATUS for details of modifications to GCML. ; Type HELP ADD GCML PARAMETERS for parameter list details. ; Type HELP ADD GCML ERRORS for details of error returns. ; Type HELP ADD GCML MODE for details of the mode control parameter. ; ;3 MODE ; Using the optional IMODE parameter, the user may modify ; the default actions of GCML, as shown below. Particular bits ; need to be set/cleared in IMODE for given actions. The ; default conditions are marked with an asterisk (*). Note ; that, since the entire IMODE parameter is copied to ; the internal GCML mode control location, not simply ; OR-ed with it, the user must ensure that all ; of the bits have their correct default values if no change ; is required. ; ; * Bit 0 set. Command lines beginning with ; are treated ; as comments, and are not returned to the caller. ; Bit 0 clear. Command lines beginning with ; are returned to ; the caller. ; * Bit 1 set. Command lines beginning with @ are treated as indirect ; command file specifiers. ; Bit 1 clear. Command lines beginning with @ are passed back to the ; calling program without being treated as indirect command ; file specifiers. ; * Bit 2 set. The command file being read is to be closed after each ; call to GCML. ; Bit 2 clear. The command file being read is not closed. In this case, ; the user must provide an additional file buffer ; using the task-builder ACTFIL command. The number ; of buffers required will be one greater than the number ; of logical units in use. ; Bit 3 set. Pass the command line to the caller without ; lower to upper case comversion. ; * Bit 3 clear. Convert any lower case characters in the command ; line to upper case before returning the line to ; the caller. ; Bit 4 set. Continuation lines allowed. ; This option should not be enabled since there is ; insufficient buffer space allocated within the ; routine to allow command lines of total length ; greater than 82 characters. ; * Bit 4 clear. Continuation lines not allowed. ; ; ;3 STATUS ; Modification List: ; M0003 Date: 12-AUG-81 B.Hillam ; Indirect command file nesting depth increased to 3 (from 1). ; ;BH M0004 13-AUG-81 Add optional mode control parameter. ;EDW M0005 24-AUG-81 Use PURE.I and IMPURE PSECT's ;BH M0006 1-SEP-81 Change PSECT IMPURE to PSECT GCMLID. ;BH M0007 23-FEB-83 Change PSECT attributes on GCMLID : RW,GBL,OVR,D ; Correct embedded command file ;EDW M0008 18-MAY-84 Change PSECT attributes on GCMLID : RW,GBL,OVR,D,SAV ; to remove overlay restriction ; ; Restrictions: ; Continuation mode is not allowed. ; When using GCML in an overlaid program, force the PSECT GCMLID ; into the root segment to avoid resetting of GCML workspace. ; This is done by ODL commands of the form ; .PSECT GCMLID,RW,D,GBL,OVR ; .ROOT MAIN-GCMLID-*(OVLAY1,OVLAY2 ... ; On M+ 2.1 or M 4.1 or greater this is done automatically ; ; ;3 PARAMETERS ; Calling Sequence: ; ; CALL GCML(ILUN,IPRMPT,ILEN,IBUF,ISIZ,IERR [,IMODE]) ; ; External Routines called: ; ; Parameter List: ; Inputs : ; ILUN INTEGER*2 parameter specifying LUN for use by GCML. ; This LUN must initially be assigned to TI:, and must ; not be used elsewhere, since GCML may re-assign it to ; indirect command files. ; ; IPRMPT LOGICAL*1 array or Hollerith string containing ; a prompt string for use when prompting the terminal. ; GCML will prefix the string by before using it. ; Should be <= 80 characters. ; ; ILEN INTEGER*2 character count for IPRMPT. ; ; IMODE INTEGER*2 optional mode control parameter for GCML. ; The default values shown above will be used if this ; parameter is not present. Any attempt to set continuation ; mode will be ignored. ; ; Outputs: ; IBUF LOGICAL*1 array to receive the command line from GCML. ; Must be dimensioned at least 82 in the calling program. ; ; ISIZ INTEGER*2 character count for IBUF. ; 0 if the command line was blank. ; ; Type HELP ADD GCML ERROR for details of the error return parameter ;3 ERROR ; IERR INTEGER*2 error return. ; 1 = Success ; -1 = I/o error during command line input ; -2 = GCML was unable to open/re-open specified command file. ; -3 = Syntax error in indirect command file name ; -5 = Attempt to exceed maximum allowed nesting depth (3). ; -10 = End-of-file detected on first (un-nested) command file. ; -16 = Command buffer too small for total number of characters. ; In this last case, the buffer contains as many ; characters as possible. ; ; In addition, any valid FCS error return may be given ; when using indirect command files. ; ; Common Blocks: ; ; NONE ; ;END .MCALL GCML$,GCMLB$ ; ; Define parameter offsets ; ILUN=2 IPRMPT=4 ILEN=6 IBUF=8. ISIZ=10. IERR=12. IMODE=14. NULARG=-1 ; .PSECT GCMLID,RW,D,GBL,OVR,SAV ;M00008 CBLOCK: GCMLB$ 3,,,,PDL ;GCML CONTROL BLOCK PDL: .BLKB 80. ;PUSH DOWN LIST PROMPT: .BLKB 82. ;PROMPT STRING .PSECT PURE.I,RO,I ;M00005 GCML:: MOV #CBLOCK,R0 ;GET CONTROL BLOCK ADDRESS MOVB @ILUN(R5),F.LUN(R0) ;SET LUN. MOV IPRMPT(R5),R2 ;SET PROMPT STRING MOV @ILEN(R5),R3 ;GET LENGTH CMP R3,#80. ;LONGER THAN 80 BYTES ? BLT 2$ ;BR IF NOT MOV #80.,R3 ;FORCE MAXLENGTH TO 80. 2$: MOV #PROMPT,R4 ;SET PROMPT MOVB #15,(R4)+ ;Prefix prompt string by MOVB #12,(R4)+ ; 3$: TST R3 ;ANY PROMPT LEFT ? BEQ 4$ ;BR IF NOT 5$: MOVB (R2)+,(R4)+ ;MOVE IT BEQ 4$ ;BR IF END OF STRING SOB R3,5$ ;DECREMENT CHARACTER COUNT 4$: SUB #PROMPT,R4 ;CALCULATE PROMPT LENGTH MOV #CBLOCK,R0 ;GET CONTROL BLOCK ADDRESS. MOV R4,G.PSDS(R0) ;SET PROMPT LENGTH MOV #PROMPT,G.PSDS+2(R0);SET PROMPT ADDRESS CMPB (R5),#7 ;7 parameters ? BLT 41$ ;LT if no CMP IMODE(R5),#NULARG ;Missing 7th argument ? BEQ 41$ ;EQ if yes MOV @IMODE(R5),-(SP);Get the parameter BR 42$ 41$: MOV #,-(SP) ;Set default mode 42$: BIC #<^C!GE.CON>,(SP) BICB #,G.MODE(R0) BISB (SP)+,G.MODE(R0) JSR PC,.GCML1 ;GET COMMAND LINE. BCS ERR ;ERROR. MOV G.CMLD(R0),R1 ;GET REPLY LENGTH MOV R1,@ISIZ(R5) ;RETURN SIZE BEQ 200$ ;BR IF ZERO MOV G.CMLD+2(R0),R0 ; MOV IBUF(R5),R3 ; 1$: MOVB (R0)+,(R3)+ ;COPY BUFFER BACK SOB R1,1$ ; 200$: MOV #1,@IERR(R5) ;RETURN SUCCESS CODE. RTS PC ;RETURN ERR: MOVB G.ERR(R0),R1 ;GET ERROR CODE CMPB #GE.IOR,R1 ;I/O ERROR ? BEQ 1$ ;IF EQ YES CMPB #GE.OPR,R1 ; BNE 2$ ;IF NE NO. 1$: MOVB F.ERR(R0),R1 ;RETURN FCS ERROR. MOV R1,@IERR(R5) ; RTS PC ; 2$: MOV R1,@IERR(R5) ;RETURN GCML ERROR. RTS PC .END