Next: libsimswedish
Up: libsim
Previous: libsimediting
libsimchario
NAME
libsimchario - support for terminal I/O
DESCRIPTION
The following operations offering some utilities for
character based terminal I/O. They are compatible with and
use sysin/sysout, but provides some additional
functionality.
EXAMPLE
external procedure OutLine;
text T;
T:-blanks(1024);
T:= loooong value ....";"
OutLine(T); ! Conveniently chopped up in ;
! 'Image.Length' size chunks.;
AUTHOR
Various people at QZ and FOA, Stockholm.
DETAILED INTERFACE
OutLine
procedure OutLine(T,Out_File);
text T; ! pos not used or chaged ;
ref (OutFile) Out_File; ! file to write on, e.g. SysOut;
Output the argument T as one or more lines of output on
Out_File. Protected against errors when the parameter text
is longer than the image, T is chopped into image size pices
and output one by one on a line each.
BreakoutLine
procedure BreakoutLine (T, Out_File);
text T; ! pos unused and unchaged ;
ref (OutFile) Out_File; ! file to write on, e.g. SysOut;
Similar to OutLine but does not output line-breaks (no
CR/LF) after each line. It uses BreakOutimage, rather than
Outimage as OutLine uses.
InLine
text procedure InLine(Question,In_File);
text Question; ! Prompt to print, pos not used;
ref(infile) In_File; ! File to read from. ;
Types 'Question' as a prompt and returns users response as a
stripped sub-text of Sysin.Image. If In_file is None, SysIn
is used for input (Sysout is always used).
LookAhead
character procedure LookAhead (fileref);
ref (File) fileref; ! Infile or Directfile object;
Locates the next non-white (space or tab) character. Calls
LastItem to scan over white space. Returns the next non-
white character (if any) but leaves pos so InChar will
return the same charcter. When at end-of-file it returns
Space!
Request
text procedure
Request(Prompt,Default,Result,Valid,ErrMsg,Help);
name Prompt,Default,ErrMsg,Help, ! In parameters /may
change;
Result, ! Out parameter;
Valid; ! Jensens device, should match expression using
'Result';
text Prompt; ! Prompt text e.g. X-value" ;"
text Default;! Default value such as 2.5" ;"
boolean Valid;! Should evaluate to 'True' if current
value of Result is OK;
text Result; ! Result, user response assigned here;
text ErrMsg; ! Error text e.g. Legal values are 1..10";"
text Help; ! Help text, e.g. Enter valid horizontal
coordinate" ;"
Outputs a prompt to the user and returns a Validated reply.
The Prompt and the Default value is displayed to the user.
Users response is assigned to Result and then Valid
(Boolean, Call-back, expression) is checked. If it evaluates
to True, Request returns otherwise the user is show the
error message ErrMsg and prompted for a better value. If
the user enter a '?', the Help text will be displayed. If
the user just hits Return, the Default is returned as
Result. Note that all parameter are called by name so any
of them can be matched with a expression or text procedure
evaluating to different values each time they are called, as
more and more verbose help texts.