;+ ; Command.Mar Version 1.0 February, 1989 ;- ; .enable suppression io_descr: .word 0 ; Command line input buffer .word 0 .long io_buffer io_buffer: .blkb 80 force_prompt: .long 0 ; Flags whether the command line ; has already been read error_descr: .ascid /Syntax error - Expecting decimal value/; Used in CVT_TO_INT .entry GET_COMMAND,^m ; ; This routine fetches any unused data from the command string. This ; allows the user to declare a foreign command with parameters. Then ; the program can be started without any prompting. ; ; Call using: Get_Command(descr OUTPUT_DESCR, descr PROMPT_DESCR) ; ; 4(ap) - Address of output descriptor ; 8(ap) - Address of prompt string descriptor ; 12(ap)- Flag use to determine if force prompting must be used. ; This is useful if there was a problem with the last item ; returned, such as an finding a string when an integer was ; expected. A common source of this error is that the user ; forgot an argument in the command string. In this case, ; the rest of the command string is suspect and should be ; flushed. ; tstw io_descr ; Any data from earlier read ? beql GET_INPUT ; If not the get more data tstl 12(ap) ; Discard current data, if any ? bneq GET_INPUT skpc #^A/ /,io_descr,@io_descr+4 ; Skip leading blanks tstb r0 ; Any data left ? bneq GET_ITEM ; If so then use it GET_INPUT: movw #80,io_descr ; Reset input descriptor moval io_buffer,io_descr+4 bisl2 12(ap),force_prompt pushal force_prompt ; Force prompting on any calls ; after the first one. The ; problem is lib$get_foreign ; always returns the same string ; unless prompting is forced. pushaq io_descr pushl 8(ap) ; Address of current prompt pushaq io_descr calls #4,g^lib$get_foreign ; Fetch data - prompt if req'd blbs r0,CVT_TABS $exit_s r0 CVT_TABS: locc #9,io_descr,@io_descr+4 ; Convert tabs to spaces movb #^A/ /,(r1) ; Might change EOS+1, is OK tstb r0 ; If not done then loop bgtr CVT_TABS skpc #^A/ /,io_descr,@io_descr+4 ; Skip leading blanks tstb r0 ; Any useful data ? bneq GET_ITEM ; If so then extract it clrw io_descr ; Else use defaults ret GET_ITEM: movl 4(ap),r6 ; Address of output descriptor cmpb #^A/"/,(r1) ; Quoted string ? bneq SIZE_ITEM SIZE_STRING: incl r1 ; Skip quote mark movl r1,r7 ; Save item start address locc #^A/"/,r0,(r1) ; Look for end of string clrb (r1) ; Clear end of string character brb EXTRACT_ITEM SIZE_ITEM: movl r1,r7 ; Save item start address locc #^A/ /,r0,(r1) ; Look for end of item EXTRACT_ITEM: movw r0,io_descr ; Fix #bytes left in string movl r1,io_descr+4 ; Fix location of string start subl3 r7,r1,r8 ; Get number of bytes to copy movw r8,(r6) ; Set number of bytes in string movc3 r8,(r7),@4(r6) ; Copy text to item string ret ; ; Convert ascii digits to binary number. If an error occurs, the command ; input buffer is flushed. THIS ROUTINE CAN AFFECT THE PERFORMANCE ; OF THE GET_COMMAND ROUTINE. It is intended that this routine be used ; only for data fetched using Get_Command. If the input type is not ; numeric then an error occurs. When a retry occurs, the next item ; on the command line would normally be returned. That would result ; in a real mess. The better solution is to flush the command line. ; ; ; 4(ap) - Output longword address ; 8(ap) - Input string descriptor address ; .entry CVT_TO_INT,^m<> tstw 8(ap) bneq DO_CVT ; If not use default value ret DO_CVT: movl 8(ap),r0 pushl 4(ap) ; Output result address pushal @4(r0) ; Input string address pushl (r0) ; Number of bytes to convert calls #3,g^lib$cvt_dtb blbc r0,HIT_ERROR ret HIT_ERROR: pushl r0 pushaq error_descr ; Print error message calls #1,g^lib$put_output clrw io_descr ; Flush any outstanding data movl -(sp),r0 ; Return error to caller ret .end