home *** CD-ROM | disk | FTP | other *** search
-
- (*
- * input.inc - library for local input and display
- * used when compiling parts of ProDOOR as local
- * (command-line) utilities.
- *
- * (C) 1987 Samuel H. Smith
- *
- * procedure disp(msg: longstring);
- * procedure newline;
- * procedure displn(msg: longstring);
- * procedure input(var line: longstring;
- * maxlen: integer);
- *
- *)
-
- var
- linenum: integer;
-
- {$IFDEF TRACEIO}
- var
- tracefd: text;
- const
- traceopen: boolean = false;
- {$ENDIF}
-
-
- (* ------------------------------------------------------------ *)
- procedure disp(msg: longstring);
- begin
- write(output,msg);
-
- {$IFDEF TRACEIO}
- if not traceopen then
- begin
- assign(tracefd,'trace.out');
- rewrite(tracefd);
- traceopen := true;
- end;
-
- write(tracefd,msg);
- {$ENDIF}
-
- end;
-
-
- procedure newline;
- begin
- flush(output);
- disp(^M^J);
- inc(linenum);
- end;
-
- procedure displn(msg: longstring);
- begin
- disp(msg);
- newline;
- end;
-
-
- (* ------------------------------------------------------------ *)
- procedure input(var line: longstring;
- maxlen: integer);
- var
- c: char;
-
- begin
- linenum := 1;
- line := '';
-
- repeat
- flush(output);
- c := readkey;
-
- case c of
- ' '..#126:
- if maxlen = 0 then
- begin
- line := c;
- disp(c);
- c := ^M; {automatic CR}
- end
- else
-
- if length(line) < maxlen then
- begin
- if (wherex > 78) then
- newline;
-
- CONCAT_CHAR(line,c);
- disp(c);
- end
- else
- disp(^G^X^H' '^H);
-
- ^H,#127:
- if length(line) > 0 then
- begin
- dec(line[0]);
- disp(^H' '^H);
- end
- else
- disp(^G);
-
- ^M: ;
-
- ^C: begin
- displn('^C');
- halt(99);
- end;
-
- else {echo ^X with invalid inputs; might stop
- an external protocol driver that is stuck}
- disp(^X^H' '^H);
-
- end;
-
- until (c = ^M);
-
- end;
-
-
-