Quote:
>In Prolog, there is no way to:
>Prompt the user to type a string (including spaces) on screen and get it
>after the user press Return (not require ".").
>Am I right?
I hope not :-) read/1 reads Prolog-terms. To read anything else you need
to use one of the character-reading predicates. These are:
get0 Good old Prolog
get_code ISO Prolog: read character code
get_char ISO Prolog: read one-character atom.
For the good old Prolog (runs on most systems, but nowadays I would use
the ISO versions):
read_line(Line) :-
read_line(user_input, Line).
read_line(S, Line) :-
get0(S, C0),
read_line(C0, S, LineChars),
name(Line, LineChars). % or atom_codes or just leave it a string
read_line(10, _, []) :- !. % \n
read_line(13, _, []) :- !. % \r
read_line(C0, S, [C0|T]) :-
get0(S, C1),
read_line(C1, S, T).
Regards --- Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jan Wielemaker Author of SWI-Prolog and the XPCE GUI library
SWI, University of Amsterdam http://www.swi.psy.uva.nl/projects/SWI-Prolog/