Sunday, 15 February 2015

prolog - Reading from user_input causes ":|" to appear in output -



prolog - Reading from user_input causes ":|" to appear in output -

my code using read_line_to_codes/2 , read_stream_to_codes/2 in order read user_input. how these reads organized:

main :- read_line_to_codes(user_input, [a]), read_line_to_codes(user_input, b), /* parsing happens here */ read_stream_to_codes(user_input, c), /* more parsing happens here , code goes on */

i compiling programme using next command:

swipl -q -t main -o programme -c program.pl

the programme runs fine, due reads in main, output |:|: characters (the swipl console shows |: whenever user has input something). when remove i/o code program, runs without outputting characters.

is there way rid of behavior?

you have utilize prompt1/1 predicate set prompt next line or prompt/2 alter prompt message globally.

e.g. using prompt1/1:

?- read_line_to_codes(user_input, l). |: test l = [116, 101, 115, 116]. ?- prompt1(''), read_line_to_codes(user_input, l). test l = [116, 101, 115, 116].

or, using prompt/2:

?- prompt(old, 'give me: '). old = '|: '. ?- read_line_to_codes(user_input, l). give me: abc l = [97, 98, 99].

prolog swi-prolog

No comments:

Post a Comment