/****^ ********************************************************* * * * Copyright, (C) BULL HN Information Systems Inc., 1990 * * * * Copyright (c) 1972 by Massachusetts Institute of * * Technology and Honeywell Information Systems, Inc. * * * ********************************************************* */ /****^ HISTORY COMMENTS: 1) change(90-05-28,Blackmore), approve(90-03-10,MCR8163), audit(90-06-04,Vu), install(90-06-19,MR12.4-1015): Fix a problem in ask_ that causes bad interactions with exec_com. END HISTORY COMMENTS */ ask_: proc (prompt, ans); /* Terminal input processor, with goodies. THE PROMPTING ENTRIES: prompt for more input if they don't get whats wanted. . call ask_ (ctl_string, answer, ioa_args ... ) will get a word from user_input. If the current line is empty, the program will format a prompting message, using the first arg as a control string and arguments from the third on as input for conversion. This message will be typed out. . call ask_$ask_int (ctl_string, int, ioa_args) will do the same thing but return an integer. The typed number may be integer or floating, positive or negative. Dollar signs and commas will be ignored. . call ask_$ask_flo (ctl_string, flo, ioa_args ... ) . call ask_$ask_line (ctl_string, line, ioa_args ... ) will return, respectively, a floating number and the rest of the line . call ask_$ask_yn (ctl_string, ans, ioa_args... ) will return either the character string "yes" or "no" . call ask_$ask_nf (ctl_string, ans, ioa_args ... ) will return either the character string "on" or "off" THE CHECKING ENTRIES: return 'flag' to indicate success or failure. . call ask_$ask_c (ans, flag) will set flag nonzero and return into ans if anything is there similarly, . call ask_$ask_cint (int, flag) . call ask_$ask_cflo (flo, flag) . call ask_$ask_cline (line, flag) . call ask_$ask_cyn (ans, flag) . call ask_$ask_cnf (ans, flag) THE PEEKING ENTRIES: don't change current position in input line. . call ask_$ask_n (ans, flag) . call ask_$ask_nline (line, flag) will work like 'ask_c' but leaves the next word there. . call ask_$ask_nflo (flo, flag) . call ask_$ask_nint (int, flag) . call ask_$ask_nyn (ans, flag) . call ask_$ask_nnf (ans, flag) are also peek entries, but will return flag as -1 if there is something on the line but it's not a number (or yes or no, or on or off). OTHER ENTRIES: . call ask_$ask_clr to reset the line buffer to empty, on the first call or in case of error. (note that you don't want to pass int static between progs) . call ask_$ask_prompt (ctl_string, ioa_args ... ) causes a new inputline to be prompted for & read in . call ask_$ask_setline (input) sets the input line. It can have a newline character or not. NOTE: the line buffer, its length and current index, are among the things kept in internal static storage by this subroutine. Initial coding 12/69, THVV Modified 7/70 to call formline_, THVV Modified 9/72 to call general_rs, THVV Modified 8/83 to allow "y" or "n" and add nf entries, Jim Lippard */ dcl (addr, index, length, min, rtrim, substr) builtin; dcl (line char (128) aligned, /* Line typed by user. */ empty bit (1) init ("1"b), /* TRUE if need another line. */ i fixed bin init (1), /* Index in line. */ nchr fixed bin (21), /* Length of line. */ prompt_len fixed bin, /* length of prompt */ blank char (1) init (" ") aligned, /* Constant blank. */ NL char (1) aligned init (" "), /* Constant newline */ tab char (1) init (" ") aligned) int static; /* Constant tab. */ dcl prompt char (*), /* Arg to ask with. */ ans char (*), /* Arg where answer goes. */ flag fixed bin, /* 1 if more on line */ int fixed bin, /* integer return */ flo float bin; /* float return */ dcl (start, j, tdg) fixed bin, /* Temps. */ arglistp ptr, /* ptr to argument list */ ftm float bin (63), /* answer for number conversion */ fpm float bin (63), /* fraction part multiplier */ oldi fixed bin, /* what 'i' was at entry. */ fracsw bit (1) aligned, /* TRUE when converting fraction */ tf char (4) aligned, /* temp for yes/no code */ (flosw, intsw, linesw, csw, nsw, ynsw, nfsw, prmsw) bit (1) aligned init ("0"b); dcl 1 ll aligned based (addr (line)), /* Overlay structure for line. */ 2 ch (0: 127) char (1) unaligned; /* ... as character array. */ dcl ioa_$nnl entry options (variable), cu_$arg_list_ptr entry (ptr), iox_$put_chars entry (ptr, ptr, fixed bin(21), fixed bin(35)), iox_$get_line entry (ptr, ptr, fixed bin(21), fixed bin(21), fixed bin(35)), iox_$user_input ptr ext static, iox_$user_output ptr ext static, ioa_$general_rs entry (ptr, fixed bin, fixed bin, char (*) aligned, fixed bin, bit (1) aligned, bit (1) aligned); dcl NL_HT_SP char (3) internal static options (constant) init (" "); dcl code fixed bin (35); /* - - - - - - - */ go to join; /* Entry to return symbol. */ ask_c: entry (ans, flag); /* entry to see if symbol, get if so */ csw = "1"b; go to join; ask_int: entry (prompt, int); /* entry to get integer */ intsw = "1"b; go to join; ask_cint: entry (int, flag); /* entry to get integer if there */ intsw, csw = "1"b; go to join; ask_flo: entry (prompt, flo); /* entry to get float */ flosw = "1"b; go to join; ask_cflo: entry (flo, flag); /* entry to get float if there */ flosw, csw = "1"b; go to join; ask_line: entry (prompt, ans); /* entry to get rest of line */ linesw = "1"b; go to join; ask_cline: entry (ans, flag); /* entry to get rest of line if there */ linesw, csw = "1"b; go to join; ask_n: entry (ans, flag); /* peek entry */ csw, nsw = "1"b; go to join; ask_nint: entry (int, flag); /* Entry to peek at next integer */ csw, intsw, nsw = "1"b; go to join; ask_nflo: entry (flo, flag); /* Entry to peek at next floating */ csw, nsw, flosw = "1"b; go to join; ask_nline: entry (ans, flag); /* Entry to peek at rest of line */ csw, nsw, linesw = "1"b; go to join; ask_prompt: entry (prompt); /* Entry to prompt & fill line */ empty, prmsw = "1"b; go to join; ask_yn: entry (prompt, ans); ynsw = "1"b; go to join; ask_cyn: entry (ans, flag); csw, ynsw = "1"b; go to join; ask_nyn: entry (ans, flag); csw, nsw, ynsw = "1"b; go to join; ask_nf: entry (prompt, ans); nfsw = "1"b; go to join; ask_cnf: entry (ans, flag); csw, nfsw = "1"b; go to join; ask_nnf: entry (ans, flag); csw, nsw, nfsw = "1"b; go to join; /* - - - - - - - - - - - - begin execution - - - - */ join: if empty then do; /* If no line in buffer. */ mt: if csw then do; /* if just looking, */ flag = 0; /* report failure */ return; /* and go */ end; read: prompt_len = 120; /* Construct prompt */ if prmsw then j = 2; /* optional ioa args start at 2 */ else j = 3; /* ... or 3, depending on entry */ call cu_$arg_list_ptr (arglistp); call ioa_$general_rs (arglistp, 1, j, line, prompt_len, "1"b, "0"b); nchr = prompt_len; call iox_$put_chars (iox_$user_output, addr (line), nchr, code); /* Prompt the user. */ reread: line = ""; nchr = 0; call iox_$get_line (iox_$user_input, addr (line), 128, nchr, code); /* Get new line into buffer. */ nchr = length (rtrim (substr (line, 1, nchr), NL_HT_SP)); if nchr = 0 then go to read; /* If line is empty, get another */ empty = "0"b; /* Mark that we have it. */ i = 0; /* Start with char. 1. */ if prmsw then return; /* go home if just prompt & read */ end; oldi = i; /* save starting position, for 'n' ents */ findb: if ch (i) ^= tab then if ch (i) ^= blank then go to first; i = i + 1; /* Skip over blank before symbol. */ if i >= nchr then go to mt; /* If chars left, keep looking. */ go to findb; /* Keep looking. */ first: start = i; /* Found start of symbol. */ if linesw then do; /* Does user want all of the rest? */ ans = substr (line, start+1, nchr-i); /* yes */ if ^nsw then empty = "1"b; /* Buffer now empty, unless peek */ go to exit; end; finde: if ch (i) = blank then go to last; /* Look for end. */ if ch (i) = tab then go to last; /* ... */ i = i + 1; /* ... */ if i >= nchr then go to last; /* If out of chars, give it out */ go to finde; /* Keep looking. */ last: if intsw then go to do_num; /* Found symbol end. Number conversion? */ if flosw then do; /* ... */ do_num: fracsw = "0"b; /* set up */ fpm = 1.0e0; /* ... */ ftm = 0.0e0; /* ... */ if ch (start) = "$" then start = start + 1; /* skip dollar sign */ if ch (start) = "-" then start = start + 1; /* skip minus, come back for it */ do j = start to i-1; /* Look at each char in symbol */ if ch (j) = "," then; /* Ignore commas */ else if ch (j) = "." then fracsw = "1"b; /* Decimal point starts fraction */ else do; /* Turn char into digit */ tdg = index ("0123456789", ch (j)) - 1; if tdg < 0 then do; badd: if csw then do; /* If conditional, get out. */ fail: flag = -1; /* something there, but she's no lady */ i = oldi; /* reset buffer index */ return; /* .. and go */ end; call ioa_$nnl ("""^a"" non-numeric. Please retype: ", substr (line, start+1, i-start)); go to reread; /* get fresh line */ end; if fracsw then do; /* OK digit. Fraction? */ fpm = fpm * 10.0e0; /* yes, compute place */ ftm = ftm + tdg/fpm; /* insert digit */ end; else ftm = 10.0e0*ftm + tdg; /* insert integer digit */ end; end; if ch (start-1) = "-" then ftm = -ftm; /* sign control */ if intsw then int = ftm; /* return value */ else flo = ftm; /* ... */ end; else if ynsw then do; /* Insist on yes or no? */ tf = substr (line, start+1, i-start); /* Get answer */ if tf = "yes" | tf = "y" then do; ans = "yes"; go to oky; end; else if tf = "no" | tf = "n" then do; ans = "no"; go to oky; end; if csw then go to fail; /* Answer neither yes nor no. If conditional, exit */ call ioa_$nnl ("""^a"" is not ""yes"" or ""no"". Please retype: ", substr (line, start+1, i-start)); go to reread; end; else if nfsw then do; tf = substr (line, start+1, i-start); if tf = "on" then do; ans = "on"; goto oky; end; else if tf = "off" then do; ans = "off"; goto oky; end; if csw then go to fail; call ioa_$nnl ("""^a"" is not ""on"" or ""off"". Please retype: ", substr (line, start+1, i-start)); go to reread; end; else ans = substr (line, start+1, i-start); /* one symbol wanted */ oky: /* Return symbol. */ exit: if csw then flag = 1; /* if conditional, report OK */ if nsw then i = oldi; /* if peeking, reset buffer ptr */ else if i >= nchr then empty = "1"b; /* Not peeking. Is buffer empty? */ return; /* And exit. */ /* - - - */ ask_clr: entry; /* Entry point to clear switches. */ empty = "1"b; /* Force read on next call. */ return; /* Exit. */ /* - - - - - - - - - - */ ask_setline: entry (input); /* Entry point to set input line */ dcl input char (*); line = input; /* fill internal static buffer */ nchr = min (length (input), 128); /* now trim the line. start at end */ i = 0; do while (nchr > 0); /* Trim trailing blanks and tabs off line. */ if ch (nchr) ^= blank then if ch (nchr) ^= tab then if ch (nchr) ^= NL then go to sltx; nchr = nchr - 1; end; sltx: if nchr > 0 then empty = "0"b; end ask_; */ ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull and Bull HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by Bull HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved */