Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/libsim/safeio.rnm
There is 1 other file named safeio.rnm in the archive. Click here to see a list.
.p 0,1,3
This manual describes the SAFEIO system for programming of safe dialogues in a SIMULA program.
SAFEIO is an interface between the user and a SIMULA program.
This document reflects version 4.0 of the SAFEIO system.
.subtitle Declaration examples
.page
1. DECLARATION EXAMPLES
.skip 2
There is another CLASS SAFEI which is
.index CLASS SAFEI
a reduced version of SAFEIO. It has only one formal parameter - the language parameter.
CLASS SAFEI performs the operations of CLASS SAFEIO minus the file
handling facilities. Thus it is possible to use SAFEIO during program development and
testing and then recompile with SAFEI.
.skip
.index Safmin
A further reduced version is SAFMIN, see SAFMIN.HLP.
.skip
Thera are also three classes SIMMIN, SIMEI and SIMEIO identical to
.index sime
.index simmin
.index simeio
.index simulation, using ^^SAFEIO\\
SAFMIN, SAFEI and SAFEIO respectively in all respects but prefixed by SIMULATION.
.skip
The SAFEIO CLASS has two formal parameters#:
.index formal parameters
.skip
.ls
.le;File specification for log file saving all accepted input from
.index log file
the start of execution - TEXT by VALUE. If actual value is NOTEXT, no log file will
be generated from start.
.index Language parameter
.index message files
.le;Message file parameter (language parm.) - TEXT by VALUE.
IF the value is NOTEXT ("")
the message file SAFEIO.ENG will be used.
If no such file exists on the user's disk area, the
SYS: version is used.
Otherwise the following procedure is followed:
.skip
_	A. If parm. contains no dot ('.'), add "SAFEIO."
.br
_	####- possibly after device colon (':').
.br
_	B. Search file on specified area.
.br
_	C. If found, use it. Else
.br
_	D. Try to find it on the SYS: area.
.br
_	E. If found there, use it. Else
.br
_	F. Print message and use SYS:SAFEIO.ENG.
.skip
In order to create an own message file (almost every message
produced by SAFEI(O) is taken from the message file) it
is recommended to start from a copy of SYS:SAFEIO.ENG
(or SYS:SAFEIO.SWE).
Class SAFEI uses the same message file(s) as SAFEIO (though only
partly).
.els
.skip 2
Example 1 - prefixing with SAFEIO.
.skip
.nofill
BEGIN
	EXTERNAL REF (Infile) PROCEDURE findinfile;
	EXTERNAL REF (Outfile) PROCEDURE findoutfile;
	EXTERNAL TEXT PROCEDURE conc,upcase,
		frontstrip,rest,checkextension;
	EXTERNAL CHARACTER PROCEDURE fetchar,findtrigger;
	EXTERNAL LONG REAL PROCEDURE scanreal;
	EXTERNAL INTEGER PROCEDURE checkreal,checkint,
		scanint,ilog;
	EXTERNAL BOOLEAN PROCEDURE menu;
	EXTERNAL CLASS safeio;

	SAFEIO("input.log","ENG") BEGIN
.skip
	.....using safeio procedures....
.skip
	END of prefixed block;
.skip
	....calculations not requiring safeio....
.skip
END of program
.skip 2
Example 2 - prefixing with SAFEI.
BEGIN
	EXTERNAL declarations ...;
	EXTERNAL CLASS safei;
	SAFEI("SAFEIO.ENG[123,456]") BEGIN
.skip
	_..... using safei procedures ....
.skip
	END of prefixed block;
.skip
	_....calculations not requiring safei....
.skip
END of program
.skip 2
Example 3 - Inspecting SAFEIO.
.skip
BEGIN
	EXTERNAL declarations ...;
.skip
	....
	INSPECT NEW safeio(NOTEXT,NOTEXT) DO
	BEGIN
		....using safeio....
		! Closing possible open files:   ;
		closefiles;
	END inspection;
.skip
	....
.skip
.fill
END of program
.skip 2
Example 4 - creating your own subclass to SAFEIO.
.skip
.nofill
safeio CLASS myclass;
BEGIN   ....   END of myclass;
.skip 1
Create your main program:
.skip
BEGIN
.skip
	EXTERNAL declarations ...;
.skip
	myclass("log","MYMESS.TXT") BEGIN
	! The log file "log.saf" will be opened.;
	! The message file MYMESS.TXT[123,456] will be used.;
.skip
		....
.skip
	END prefixed block
.skip
END of program
.fill
.subtitle 3. SAFEIO REQUEST AND INPUTCHECKING PROCEDURES
.page
2. SAFEIO REQUEST AND INPUTCHECKING PROCEDURES
.skip 2
2.1 REQUEST PROCEDURE
.skip 2
.p 0,1,3
The main procedure when programming with SAFEIO is REQUEST :
.index REQUEST
.skip
request
(promptingquestion,defaultvalue,inputok,errormessage,help);
.skip
The parameters are :
.skip
.ls
.le;Promptingquestion - TEXT by VALUE -	The prompting question preferably ending with some
.index Promptingquestion
prompting character as ':'. This text will be printed on the user's terminal
followed by a call to Breakoutimage.
.le;Defaultvalue - TEXT by NAME -	The value which should be accepted if
.index Defaultvalue
the user answers with just Carriage Return (i.e. an empty answer).
The default value will be presented to the user in the following manner#:
.skip
Enter input:/55/:
.skip
assuming the the prompting question was "Enter input:" and the default
value was "55". The '/' is the value of a SAFEIO attribute character
DEFAULTQUOTE and may be changed by the programmer. Likewise the final ':'
.index defaultquote
is the initial value of character attibute PROMPTINGCHAR.
.index promptingchar.
If no default answer should be allowed the SAFEIO attribute NODEFAULT may
.index nodefault
be used (in which case the defaultquotes and the promptingchar
will not be displayed).
.le;Inputok - BOOLEAN by NAME -	This parameter shall be true
.index Inputok
if the input is to be accepted else false. Usually the actual
parameter consists of a call to a syntax and validity checking
.index syntax and validity checking
procedure (see Inputchecking Procedures).
.le;Errormessage - TEXT by NAME -	The text will be printed on the
.index Errormessage
user's terminal if inputok is evaluated to be false and the SYNTAXOK flag
.index syntaxok flag
(a SAFEIO boolean attribute) is true.
.le;Help - BOOLEAN by NAME -	This parameter will be evaluated each
.index Help
time the user types in an answer starting with a questionmark '?'.
.els
.page
2.2 INPUTCHECKING PROCEDURES
.skip 2
The syntax and validity checking procedures are#:
.ls
.le;Intinput
.index Intinput
.le;Realinput
.index Realinput
.le;Longrealinput
.index Longrealinput
.le;Textinput
.index Textinput
.le;Boolinput
.index Boolinput
.els
The general structure of a syntax and validity checking
procedure is :
.skip
.nofill
BOOLEAN PROCEDURE ***input(result,validity);
NAME result,validity;   *** result;   BOOLEAN validity;
BEGIN
	COMMENT The input line is stored in currentfile.Image;
.skip
	IF ...syntax is OK... THEN
	BEGIN
		COMMENT Get value from currentfile.Image: ;
		result:= ...;
		syntaxok:= TRUE;
		COMMENT syntaxok is a global SAFEIO attribute. ;
.break
		COMMENT Since the parameter transmission mode
		is by NAME the actual validity parameter may be
		(and often is) an expression containing the
		result variable. ;
		check:= IF checkvalidity THEN validity
			ELSE TRUE
	END ELSE
	BEGIN   Outtext( for example: ? Illegal *** input: );
		Outtext( the rest of the stripped
			currentfile.Image );
		Outimage;
		syntaxok:= FALSE
	END error
.skip
END of check;
.skip
.fill
The type of result (***) depends on the procedure in an obvious manner.
.skip
The programmer may use the procedure skeleton presented above in order
to design his own checking procedures.
.skip
The predefined SAFEIO procedures will only accept input lines containing a legal item
of the corresponding type and nothing else.
.Skip
.index checkvalidity
If, however the programmer codes CHECKVALIDITY:= FALSE then no
validity checking will be done. Though saving (may be) lots of
execution time this should be used with care, since the security
enabled through validity checking will be lost!
.skip
The textinput procedure will accept any character sequence as
.index textinput
a syntactically correct input.
.skip
The boolinput procedure, however, has just one parameter; result.
.index boolinput
There is no use putting the prompting question if just one of the
yes/no (true/false) alternatives is valid!
.skip
The intinput, realinput
.index realinput
.index intinput
and longrealinput procedures will reject not only items not conforming
.index longrealinput
to the correct syntax, but also such numeric input that otherwise would have caused
a run time arithmetic overflow error.
.skip
For convenient simple command validity checking the LIBSIM boolean procedure
MENU may be used as the actual parameter to an ***input procedure.
(For texts with national characters - }{` $_#@  - use procedure MENY instead.)
.index menu
.index meny
.skip
The MENU procedure will return the value TRUE if a nonambiguous
match is found (though an exact match is always accepted - even
if it is a substring of another table element).
The index parameter will indicate the table index
for which the match was found. If no match is found it will
return zero. If t is ambiguous the index will be set to -1.
The contents of t will be converted to upper case letters.
.skip
Note that the table must contain upper case letters only
and no blanks at the end of the text.
.skip
An example of the use of MENU#:
.skip
.nofill
....
SAFEIO("","") BEGIN   TEXT t;   TEXT ARRAY table[1:5];
	INTEGER index;
	SWITCH action:= start,stop,delete,delayed,delay;
.skip
	table[1]:- Copy("START");
	table[2]:- Copy("STOP");
	table[3]:- Copy("DELETE");
	table[4]:- Copy("DELAYED");
	table[5]:- Copy("DELAY");
.skip
	request("*",nodefault,
	textinput(t,menu(t,index,table,5)),
.index commandmessage
	commandmessage(index),		! SAFEIO PROC. attribute
					! answering with proper
					! error message.;
.index commandhelp
	commandhelp(table,5));		! SAFEIO PROC. attribute
					! displaying available
					! commands in TABLE.;

.skip
	GO TO action[index];
.skip
	start: ...
	stop: ...
	delete: ...
	delayed: ...
	delay: ...
....
.skip
.fill
The following input strings will be accepted#:
.break
START
.break
start
.break
Start
.break
sta
.break
dele
.break
delaye
.skip
while the following will be rejected#:
.skip
S
.break
st
.break
del
.break
dela
.break
xxx
.skip 2
2.3 HELP PROCEDURES
.skip
There is two SAFEIO boolean help procedures, HELP and NOHELP.
.index help procedure
.index nohelp procedure
Procedure HELP takes one text parameter (by NAME).
If the text is longer than Sysout.Length then the text
will be copied and displayed with Carriage Return substituted for relevant
blanks.
Procedure NOHELP will simply inform the user than the programmer
was too lazy to provide any help information.
.page
.subtitle 4. SAFEIO COMMANDS
.page
3. SAFEIO COMMANDS
.SKIP 2
The following facilities are included in the SAFEIO class.
.skip
.ls
.le;Substituting terminal input for disk file input.
.le;Creating log files saving all accepted input.
.els
.skip
A SAFEIO command may be typed in at any question (call of request)
.index SAFEIO command
during the conversation.
.skip 2
3.1 CLASS SAFEI
.skip 2
There exists another class - SAFEI which should
be used if these facilities are not wanted. The SAFEI class has just one
.index SAFEI class
formal parameter - the language parameter.
.skip
The following code could be used if a log file should be generated
when using SAFEI#:
.nofill
.skip 2
BEGIN
    EXTERNAL declarations ...;
.skip
    safei("eng") BEGIN
.skip
.skip
	REF (Outfile) recordfile;   TEXT recordname;
.skip
	PROCEDURE
	askfor(prompt,default,inputok,errormessage,help);
	NAME prompt,default,inputok,errormessage,help;
	TEXT prompt,default,errormessage;
	BOOLEAN inputok,help;
	BEGIN
	    request(prompt,default,inputok,errormessage,help);
	    INSPECT recordfile DO Outimage
.skip
	END of askfor;
.skip
.skip
	request("Log file:",nodefault,
	textinput(recordname,TRUE),"",nohelp);
.skip
	IF recordname =/= NOTEXT THEN
	BEGIN
	    recordfile:- NEW Outfile(recordname);
	    recordfile.Open(Sysin.Image)
	END name given;
.skip
	! for example: ;
	askfor("i:","2",intinput(i,i>0),"? Must be > 0.",nohelp);
.skip
	... etc. using askfor instead of request ...
.skip
	INSPECT recordfile DO Close;
.skip
    END safei
.skip
END of program
.fill
.skip 2
3.2 CONTROLLING LOG FILES
.index controlling log files.
.skip
The following commands may be used in order to control a log file#:
.skip
.left margin 8
.indent -8
!_>######By typing  "!_>filespec" (where filespec is a file specification)
the user will open a new log file. If another log file already is
.index log file.
active he will be told so and no new file will be created.
.skip
By typing "!_>" (with nothing after the _>) the current log
file will be closed. If no log file is active the user will
be told so. When the log file has been closed a subsqeuent
"!_>filespec" with the same file name will destroy the old contents of the file
(when the new log file is closed).
.skip
.indent -8
!+######By typing "!+" the current log file will be closed and then
immediately opened again in such way that the following log information
will be added to the file (so called append mode). If no log file
.index append mode
is active the user will be told so.
.skip
.indent -8
.left margin 0
.skip
The created log file(s) will contain the prompting questions as well as
the submitted and accepted answers.
.skip 2
3.3 CONTROLLING INPUT FILES
.index Controlling input files
.skip
The user may at any question demand that input should be read from a disk
file. The input file can be of two formats#:
.index formats 
.skip
.ls
.le;Containing just the answers - with one answer on each line.
No line may be longer than Max(80,Sysout.Length) characters
(could be easily changed in the SAFEIO code).
.le;SAFEIO log file format.
.els
.index EOF, virtual label
.index End-of-file on ^Sysin
If Sysin.Endfile becomes TRUE, a jump to VIRTUAL LABEL EOF will occur.
If the user block has such a label, then the program exexcution
will continue there. Otherwise the block will terminate through an
internal safeio jump. NOTE! Once Sysin.Endfile becomes TRUE - which
happens if the user types _^Z - no more input on Sysin is possible.
.index Control-^Z
.index _^Z
.skip
The following commands are available#:
.skip
.left margin 8
.indent -8
!__######By typing "!__filespec" the user may request that the answer for
the current question and those following should be read from a disk file.
The SAFEIO system will print on the terminal the activated questions
and the read-in answers (could be suppressed by typing != or starting and ending
the input file with !=).
There is no (soft) way to interfere with the reading process which
will continue until the file is exhausted. The user will be informed
when end of file has been encountered.
.skip
.indent -8
!<######By typing "!<filespec", however, the user requests
the disk file to be read in a stepwise manner demanding acknowledgement
.index read in a stepwise manner
from the user's terminal for each question.
The user may either accept the file input by pressing the return key
or supersede the input by typing in a new input value.
.index superseed the input
.skip
By typing "!__" (with nothing after the underline symbol)
reading will continue without waiting for acknowledgements
(in the manner of the "!__filespec" case).
.skip
By typing "!<" the current input file will be closed.
If another input file had started the one just closed - the original
input file will be resumed.
.skip
.indent -8
!_^######By typing "!_^" all active input files will be immediately closed.
.left margin 0
.skip
An input file may contain SAFEIO commands - for example switching
to other input files. Mixing "!__.." and "!<.." modes during
the nested input switching is allowed. In order to avoid run
time error if the number of simulataneous open files
exceeds SIMULA system limit (total of 16), the MAXFILES
integer attribute of SAFEIO is set to 10. If this limit is
exceeded a message will be displayed and no more files
will be opened unless some files are closed first.

.skip
Comments may be inserted in an input file by starting the line with
.index Comments
"!C.... or "!;..... In the latter case the input line will be displayed
on the user's terminal when read in.
.skip
If the input file is a SAFEIO log file (created earlier but optionally
during the same run) the prompting question must be equal to the
question field in the file. (This check may be switched off
by coding   CHECKPROMPT:= FALSE;.)
.index checkprompt
.skip 3
The SAFEIO command facilities may temporarily be switched off
by the programmer by coding#:
.skip
SWITCHCHAR:= ' ';
.index switchchar
.skip
They could be switched on again by coding#:
.skip
SWITCHCHAR:= '!';
.skip
or any other suitable character (don't use digit, sign,
dot, questionmark or letter).
.skip
(In a similar way all the triggering characters may be changed - see
.index triggering characters
the end of the source code of SAFEIO.)
.skip 2
3.4 ADDITIONAL SAFEIO COMMANDS
.index Additional SAFEIO commands
.skip
.left margin 8
.indent -8
!%######By typing "!%" the user will indirectly call a SAFEIO
virtual procedure SPECIAL (with no parameters). Since it is virtual
.index SPECIAL
the programmer may define his own procedure SPECIAL.
The current input state will be#:
.break
the reference to current image is CURRENTFILE.IMAGE and
.break
the position equals three.
.skip
The programmer may decode the rest of the input line in his own way.
.skip
.indent -8
!_&xx####By preceding an answer with "!_&" the validity checking for the
current question will be overridden. The programmer may short-circuit
this facility by calling the procedure NOOVERRIDE. (It could be reset
.index NOOVERRIDE.
by coding  OVERRIDECHAR:= '_&'.)
.index overridechar
.skip
.left margin 0
The following commands will change the value of the presented switches
.index switches
in the manner  switchx:= NOT switchx.
.skip
.left margin 8
.indent -8
!*######By typing "!*" the user will change the switch controlling the
function displaying the prompting question (attribute DISPLAYPROMPT).
.skip
.indent -8
!/######By typing "!/" the user will change the switch controlling the
function displaying the default value (attribute DISPLAYDEFAULT).
.skip
.indent -8
!=######By typing "!=" the user will change the switch controlling the
function displaying prompting question, default value and
the disk file input value. The *- and /-switches will be set to the
resulting value of the =-switch (attribute DISPLAYINPUT).
.skip
.indent -8
![######By typing "![" the user will change the switch controlling the
function displaying the file status messages (attribute TRACE).
.index file status messages.
.skip
.indent -8
!?######By typing "!?" the user will be presented a list of
the available SAFEIO commands.
.skip 2
.left margin 0
Anything else will just display the prompting question.
However, input starting with !!xxx where xxx is
an integer in the interval 7 - sysin.length will be read as
a line with its contents equal to the rest of the original line
starting at pos xxx.
This facility is mainly used when reading earlier
generated log files.
.page
.subtitle 5. SUMMARY OF CLASS SAFEIO ATTRIBUTES
4. SUMMARY OF CLASS SAFEIO ATTRIBUTES
.skip 2
.nofill
.nojustify
CLASS safeio(savefilename,language);   VALUE savefilename,language;
.index language
.index savefilename
TEXT savefilename,language;
VIRTUAL: PROCEDURE special;   LABEL eof;
BEGIN
.skip
.index printint
    PROCEDURE printint(i);   INTEGER i;
    ! Printint prints the integer i without leading
    ! spaces in Putfrac(i,0) format. ;
    ....;
.skip
.index printreal
    PROCEDURE printreal(x);   REAL x;
    ! Printreal prints the value of x without leading zeros
    ! using Putfix format if eight significant
    ! digits could be display that way, else Putreal. ;
    ....;
.skip
.index fracput
    TEXT PROCEDURE fracput(i);   INTEGER i;
    ! Returns a text reference (NOT an new text!) with a value
    ! of i without leading spaces in Putfrac(i,0) format.;
    ....;
.skip
.index intput
    TEXT PROCEDURE intput(i);    INTEGER i;
    ! Ditto Putint format.;
    ....;
.skip
.index realput
    TEXT PROCEDURE realput(x);   REAL x;
    ! Ditto Putfix/Putreal format.;
    ....;
.skip
.index outline
    PROCEDURE outline(t);   VALUE t;   TEXT t;
    ! Prints the text T on Sysout without error even if
    ! T.Length > Sysout.Length. Also calling Outimage.;
    ....;
.skip
.index irange
    BOOLEAN PROCEDURE irange(test,low,high);
    INTEGER test,low,high;
    ! Returns TRUE if low <= test <= high.;
    ....;
.skip
.index range
    BOOLEAN PROCEDURE range(test,low,high);
    REAL test,low,high;
    ! Ditto for REAL variables.;
    ....;
.skip
.index outofirange
    TEXT PROCEDURE outofirange(low,high);
    INTEGER low,high;
    ! Returns a text reference containing a complete
    ! errormessage with upper and lower limits indicated.;
    ....;
.skip
.index outofrange
    TEXT PROCEDURE outofrange(low,high);
    REAL low,high;
    ! Ditto for REAL variables.;
    ....;
.index commandhelp
    BOOLEAN PROCEDURE commandhelp(table,n);
    TEXT ARRAY table;    INTEGER n;
    ! Displays the contents of TABLE[1:N] on the user's terminal.;
    ....;
.skip
.index commandmessage
    TEXT PROCEDURE commandmessage(index);   INTEGER index;
    ! Returns a text reference indicating that the user's
    ! answer was "UNKNOWN" (index=0) or "AMBIGIOUS" (index NE 0).
    ....;
.skip
    PROCEDURE special;
.index PROCEDURE special
    ! The programmer may specify his own procedure special
.index special
    ! (with exactly that name and no parameter). Since it
    ! is virtual the local procedure will be called when the
    ! user types in '!%'.
    ! Note that the programmer may implement code for analysing
    ! the rest of the currentfile.image following the '!%'.
    ! Note also that the special procedure may call other
    ! procedures which in turn may have parameters.
    ! This declaration has the sole purpose of avoiding run time
    ! error ("No virtual match") if the programmer has not
    ! declared his own special procedure. ;
    ....;
.skip
    PROCEDURE cmdclose;
.index cmdclose
    ! This procedure closes all open input SAFEIO files.
    ! If no input file is used a message is printed. ;
    ....;
.skip
    PROCEDURE recordclose;
.index recordclose
    ! This procedure will close the recording (log) file.
    ! If no recordfile is open no action is taken. ;
    ....;
.skip
    PROCEDURE recordappend;
.index recordappend
    ! This procedure closes the current recording file and opens
    ! it again in append mode. The programmer may insert calls to
    ! recordappend whenever he wants this kind of checkpoint.
.index checkpoint.
    ! The user may call the procedure by typing in '!+'. ;
    ....;
.skip
    CLASS fileitem(file,filename,wait);
.index fileitem
    VALUE filename;   TEXT filename;
    ! Class fileitem describes the elements in the input
.index Class fileitem
    ! file stack.
    ! Since input file calls ('!<' and '!_') may be nested we
    ! need this class. The currentitem (REF (fileitem) )
    ! always points at the top of the stack. Usually the
    ! currentfile (REF (Infile) ) points at currentitem.file.
    ! However when an illegal or invalid input has been
    ! read, currentfile will temporarly be switched to Sysin.
    ! The filename is used to remember the filenames of the input
    ! files.
    ! The wait attribute flags the wait/nowait state of the input
.index wait
.index wait attribute
    ! operations. ;
    REF (Infile) file;   BOOLEAN wait;
    BEGIN   REF (fileitem) p,s;
.skip
	PROCEDURE up(x);   REF (fileitem) x;
.index up
	! The procedure up will add a new input file to
	! the stack.
	! The new file will be opened. ;
	....;
.skip
	PROCEDURE down;
.index down
	! This procedure removes the top element of the
	! stack if not equal to Sysin (when a message will
	! be issued). ;
	....;
.skip
    END OF FILEITEM;
.skip
    BOOLEAN PROCEDURE nohelp;
.index nohelp
    ! The nohelp procedure issues a message that no special help
    ! information is available. The programmer is however
    ! encouraged to define his specific help procedures
    ! when using the request procedure. ;
    ....;
.skip
    BOOLEAN PROCEDURE help(message);
    NAME message;   TEXT message;
    ! This procedure will display the contents of message on the
    ! user's terminal. If the message is longer than Sysout.Length
    ! it will be typed out with a new line at the first blank
    ! found after scanning the (rest of the) text from the right
    ! starting at Sysout.Length positions from start.
    ....;
.skip
    BOOLEAN PROCEDURE intinput(result,valid);
.index intinput
    ! This procedure checks that the rest of the
    ! currentfile.image contain exactly one integer item
    ! (and nothing more).
    ! If so syntaxok will be flagged true (so that the
.index syntaxok
    ! errormessage in the request may be printed) and the intinput
.index errormessage
    ! will return the value of the dynamically evaluated
    ! parameter valid (which usually is a boolean expression).
    ! Otherwise a message will be issued and syntaxok will
    ! be flagged false. ;
    NAME result,valid;   INTEGER result;   BOOLEAN valid;
    ....;
.skip
    BOOLEAN PROCEDURE realinput(result,valid);
.index realinput
    ! This procedure checks a real item. Otherwise as intinput. ;
    NAME result,valid;   REAL result;   BOOLEAN valid;
    ....;
.skip
    BOOLEAN PROCEDURE longrealinput(result,valid);
.index longrealinput
    ! This procedure checks a real item in double
    ! precision. The syntax checking does not differ from that
    ! in realinput, but the result parameter is long real so
    ! that long results may be returned. ;
    NAME result,valid;   LONG REAL result;   BOOLEAN valid;
    ....;
.skip
    BOOLEAN PROCEDURE boolinput(result);
.index boolinput
    NAME result;   BOOLEAN result;
    ! The boolinput procedure has one parameter only. The
    ! validity check is of course unnecessary for boolean
    ! parameters. Accepted input depends on the contents
    ! of the SAFEIO.language file.
    ! The input line may contain lower case letters.
    ! In the English case it is YES, NO, TRUE OR FALSE.
    ! P} svenska g{ller JA, NEJ, SANN eller FALSK.;
    ....;
.skip
    BOOLEAN PROCEDURE textinput(result,valid);
.index textinput
    ! This procedure returns a copy of the stripped
    ! rest of the input line.
    ! The syntax is always considered correct.;
    NAME result,valid;   TEXT result;   BOOLEAN valid;
    ....;
.skip
    PROCEDURE request(prompt,default,inputok,errormessage,help);
.index request
    ! The request procedure has the following parameters:
    ! Prompt	is the prompting question, often ending with a
.index Prompt
    !		prompting character as ':'.
    ! Default	is the default text value. If default action is
.index Default
    !		to be prohibited, the nodefault variable should
    !		be used.
    ! Inputok	shall become true if the input is to be accepted,
.index Inputok
    !		else false. Usually the actual parameter is a
    !		call to an ***input procedure.;
    ! Errormessage is a text that will be printed if inputok is
.index Errormessage
    !		is false and syntaxok is true (c.f. comment
    !		for intinput).
    ! Help	is a boolean parameter which will be
.index Help
    !		evaluated each time the user starts his answer
    !		with a questionmark '?'.
    !;
    VALUE prompt;   NAME default,errormessage,inputok,help;
    TEXT prompt,default,errormessage;   BOOLEAN inputok,help;
    ....;
.skip
    PROCEDURE nooverride;
.index nooverride
    ! A call of nooverride shortcircuits the '!_&' override
    ! validity test facility. See procedure switchtest. ;
    ....;
.skip
    PROCEDURE switchtest(mustprompt,continue,help); 
.index switchtest
    ! This procedure takes care of all input lines starting with
    ! '!' or '?'. ;
    LABEL mustprompt,continue;    PROCEDURE help;
    ....;
.skip
    PROCEDURE switchhelp;
.index switchhelp
    ! This procedure prints information on the SAFEIO commands. ;
    ....;
.skip
    PROCEDURE cmdswitch(c,continue);   CHARACTER c;
.index cmdswitch
    LABEL continue;
    ! This procedure takes care of !< and !__ commands. ;
    ....;
.skip
    PROCEDURE recordswitch;
.index recordswitch
    ! This procedure takes care of the !_> command. ;
    ....;
.skip
    PROCEDURE closefiles;
.index closefiles
    ! Close all open input and recording SAFEIO files. ;
    ....;
.skip

.index currentitem
.index currentfile
.index record
.index recordname
.index mainprompt
.index cmdname
.index cmd
.index posfield
.index defaultextension
.index nodefault
.index message
.index displayinput
.index displayprompt
.index syntaxok
.index trace
.index overrideflag
.index checkprompt
.index inputsaved
.index displaydefault
.index waitforsysin
.index margin
.index recordfile
.index record
.index cmd
.index defaultextension
.index nodefault
.index displaydefault
.index syntaxok
.index checkprompt
.index trace
.index displayinput
.index displayprompt
.index currentfile
.index currentitem
.index margin
.index switchchar
.index recordchar
.index cmdchar
.index cmdnowaitchar
.index closechar
.index displaychar
.index tracechar
.index promptswitchchar
.index helpchar
.index appendchar
.index inputchar
.index specialchar
.index overridechar
.index commentchar
.index defaultquote
.index promptingchar
.index recordswitch
.index closefiles
    REF (Infile) currentfile;   REF (fileitem) currentitem;
    TEXT cmd_buffer,mainprompt,recordname,record_buffer,
    nodefault,defaultextension,posfield,u;
    TEXT ARRAY message[1:91];
    BOOLEAN trace,syntaxok,displayprompt,displayinput,
    displaydefault,inputsaved,checkprompt,overrideflag,
    waitforsysin;
    REF (Outfile) recordfile;
    INTEGER margin,cmdcount,maxcmdfiles,reqcount;
    CHARACTER cmdchar,recordchar,displaychar,tracechar,
    promptswitchchar,switchchar,cmdnowaitchar,helpchar,
    inputchar,promptingchar,defaultquote,closechar,
    commentchar,appendchar,specialchar,overridechar;
.skip
    ! Length of images may be increased. ;
    u:- Blanks(20);
    maxcmdfiles:= 10;
    cmd_buffer:- Blanks(IF Length > 80 THEN Length ELSE 80);
    record_buffer:- Blanks(cmd_buffer.Length);
.skip
    readmessages;
.skip
    ! Set up initial values. ;
.skip
    nodefault:- message[76];    defaultextension:- message[77];
.skip
    checkprompt:=
    syntaxok:= displaydefault:= displayprompt:=
    displayinput:= trace:= TRUE;
.skip
    currentfile:- Sysin;
    currentitem:-
    NEW fileitem(currentfile,message[78],waitforsysin);
.skip
    ! May be changed to zero if no indentation of answers
    ! is wanted. Could also be increased if very long questions. ;
    margin:= 35;
.skip
    ! All these characters may be changed. However be
    ! carefull for clashes. See procedure switchtest about the
    ! testing order. Note the possibility to shortcircuit
    ! a facility by setting the corresponding character
    ! to ' '. ;
.skip
    cmdchar:= '<';
    recordchar:= '>';
    helpchar:= '?';
    displaychar:= '/';
    tracechar:= '[';
    promptswitchchar:= '*';
    inputchar:= '=';
    switchchar:= '!';
    cmdnowaitchar:= '__';
    defaultquote:= '/';
    promptingchar:= ':';
    specialchar:= '%';
    overridechar:= '_&';
    appendchar:= '+';
    commentchar:= ';';
    closechar:= '_^';
.skip
    ! Initializing recordfile from start. ;
    IF savefilename =/= NOTEXT THEN
    BEGIN   Sysin.Image:= savefilename;   Sysin.Setpos(1);
	recordswitch;   Sysin.Setpos(0);
    END;
.skip
    ! Eliminating page skipping on Sysout. ;
    INSPECT Sysout WHEN Printfile DO Linesperpage(-1);
.skip
    INNER;
.skip
    ! Jump here if Sysin.Endfile is TRUE:;
    eof:
.skip
    closefiles;	! NOTE. SAFEI and SIMEI has no such procedure.;
.skip
END of safeio;
.subtitle 6. RESTRICTIONS
.page
5. RESTRICTIONS
.skip 2
.fill
The following restrictions are valid for the SAFEIO version 4.0.
.index restrictions
.skip 2
.ls
.le;Input texts will be stripped of blanks from the right and
stripped of blanks and tabs from the left.
.le;The input starting with "?" cannot be transferred to a text.
.le;Texts starting with the current value of switchchar (initially '!')
cannot be transferred.
.le;The image length of sysout may not be less than the longest
text in the message file.
.le;Length of input lines may not exceed image length of sysout.
.le;Input lines ending with formfeed (FF) or vertical tab (VT)
will be ignored by SAFEIO.
.els
.subtitle 7. INDEX
.page
6. INDEX
.skip 2
.print index