.TITLE GETKEY - GET UNDEFINED KEYS .SBTTL GETKEY - TITLE PAGE .IDENT /V01.00/ .ENABL LC ; ; Get any undefined parameters. ; ; Version: V01.00 ; ; Author: R.W. Stamerjohn ; ; Modification history: ; ; V01.00 RWS 14-Oct-1984 Initial version .SBTTL GETKEY - DECLARATIONS .DSABL GBL .DSABL CRF ; ; Macro library calls: ; .MCALL QIOW$S ;Issue I/O and wait ; ; Global declarations: ; .GLOBL GETKEY ;Entry point ; ; Global references: ; ; CCS subroutines. ; .GLOBL CCSERR ;Declare CCS error and exit. .GLOBL GETLIN ;Get next input line. ; ; CCS symbols. ; .GLOBL TLUN ;Terminal lun .GLOBL TEFN ;Terminal event flag .GLOBL PSIZ ;Size of PBUF ; ; CCS data areas. ; .GLOBL IBUF ;Input/text buffer .GLOBL PBUF ;Parameter buffer .GLOBL PBUFL ;Length of space left in PBUF .GLOBL PBUFB ;Pointer to current position in PBUF .GLOBL PNTR0 ;Start of parameter area .GLOBL PNTR1 ;Start of parameter area .GLOBL PMIN ;Minumum number of parameters .GLOBL PMAX ;Maxumum number of parameters ; ; Other symbols. ; .GLOBL IO.RPR ;Read with prompt .GLOBL IS.CR ;Success return .ENABL CRF .SBTTL GETKEY - LOCAL DECLARATIONS ; ; Local Symbols. ; ; None. ; ; Local Data. ; IOSTS: .BLKW 2 ;I/O status .NLIST BEX ERPERR: .ASCIZ /CCS - Error processing prompt string/ .EVEN .LIST BEX .SBTTL GETKEY * SCAN FOR COMMAND ; ;+ ; This routine checks if enough numerical parameters have been defined ; and if not, inputs the prompts for parameters and prompts for the ; parameters which have not been defined. ; ; A prompt string has the followin format ; ; ?n ; ; Call by: JSR PC,GETKEY ; ; File open on input lun and PMIN/PMAX set to keyword ; address and size. ; ; Exit with: CC = Parameter requirements satisfied ; CS = User reponded with ^Z to prompt ;- GETKEY:: ;Ref. label MOV #PBUF,PBUFB ;Set address to store prompt input MOV #PSIZ,PBUFL ;Set address of parameter buffer ; ; Get what we have defined already. ; MOV #PNTR1,R0 ;Get address of %1 MOV #9.,R1 ;Get loop counter CLR R5 ;Clear counter of defined parameters 1000$: TST (R0)+ ;Is parameter defined? BEQ 1100$ ; If EQ - no, skip INC R5 ;Count parameter 1100$: TST (R0)+ ;Skip over address field SOB R1,1000$ ; and check next parameter ; ; Do we have enough to quit. ; CMP R5,PMIN ;Is the minumum defined? BGE 9998$ ; If GE - yes, all done 2000$: CMP R5,PMAX ;Have we filled the maximum? BGE 9998$ ; If GE - yes, all done ; ; Input next line and check for prompt string. ; 3000$: CALL GETLIN ;Get next input line BCS 3100$ ; If CS - input problems CMPB #<'$>,(R4) ;Is this a keyword string? BEQ 3000$ ; If EQ - yes, keep inputting CMPB #<'?>,(R4)+ ;Is this a prompt string? BNE 3100$ ; If NE - no, into action lines CMP #3,R3 ;Is line minumum length BGT 3100$ ; If GT - yes, output error MOVB (R4)+,R0 ;Get parameter character SUB #<'0>,R0 ;Convert to binary BLT 3100$ ; If LT - illegal character CMP #9.,R0 ;Was character a digit BGE 3010$ ; If GE - yes, continue SUB #<'A-'0>,R0 ;Check for A,B,C BLT 3100$ ; If LT - illegal character CMP #3,R0 ;Is this at A,B,C BLT 3100$ ; If LT - illegal character ADD #10.,R0 ;Index to PNTRA 3010$: ASH #2,R0 ;Make into double-word index ADD #PNTR0,R0 ;Get index to parameter TST (R0) ;Is parameter defined? BNE 3000$ ; If NE - yes, skip BR 4000$ ;Continue ; ; Either illegal promot, at EOF, or in action lines, output error. ; 3100$: CALL CCSERR ;Output error and exit .WORD ERPERR ; *** Error inputting prompt *** ; ; Setup prompt string and issue read with prompt. ; 4000$: MOV R3,-(SP) ;Save prompt length MOV #IBUF,R2 ;Get input buffer address SUB #2,R3 ;Subtract out leading ?n length 4100$: MOVB (R4)+,(R2)+ ;Copy string in buffer SOB R3,4100$ ; and loop till done MOVB #<'?>,(R2)+ ;Insert trailing ? MOVB #<' >,(R2)+ ;Insart trailing space MOV (SP)+,R3 ;Get size back QIOW$S #IO.RPR,#TLUN,#TEFN,,#IOSTS,, ; ; Check if successful and string address and length of input. ; CMP #IS.CR,IOSTS ;Was input OK? BNE 9997$ ; If NE - no, exit with CS MOV IOSTS+2,(R0)+ ;Set size of input MOV PBUFB,(R0)+ ;Set address of string ADD IOSTS+2,PBUFB ;Advance buffer pointer SUB IOSTS+2,PBUFL ; and update remaining length INC R5 ;Count parameter input BR 2000$ ; and loop for next ; 9997$: SEC ;Set error return BR 9999$ ; and exit 9998$: CLC ;Set success return 9999$: RETURN ;Return to caller .END