Using read with write

mangpp, created Jan 13. 2015 I'm trying to write some text then get a value from the user, eg getUserInput(Prompt, UI) :- nl, write(Prompt), write(': '), read(UI). But it always does the read first? Am I missing something simple?

Comments

Re: Using read with write

mangpp, created Jan 15. 2015 Thank you Jan. I am grateful for your kindness.

Re: Using read with write

Jan Burse, created Jan 14. 2015 Hi, Contrary to Prolog systems such as SWI-Prolog, there is no automatic flush when switching from write to read. So you need to insert a flush_output call before the read. getUserInput(Prompt, UI) :- nl, write(Prompt), write(': '), flush_output, read(UI). Bye P.S.: The predicate is ISO standard and documented here http://www.jekejeke.ch/idatab/doclet/prod/en/docs/05_run/10_docu/05_frequent/07_theories/19_stream/02_bytes.html