ECLiPSe provides the user with the ability to perform i/o on its predefined streams as well as on the dynamically opened ones. ECLiPSe stream identifiers which correspond to the predefined streams are
where the third parameter specifies if the stream must be open for INPUT or OUTPUT.p_example(sval, stag) value sval; type stag; { stream_id stream; Get_Stream(sval, stag, OUTPUT, stream) ... }
There are two main functions to perform i/o on Prolog streams: formated printing in the usual C way is done by
is similar to fprintf(3) in that its first argument is a stream identifier, the second one is a string which specifies the format in the style of printf(3) and the rest is a variable number of arguments to be printed.Fprintf(stream, format, arg1, arg2, ...)
Prolog terms can be output with the function
which outputs the term with tag tag and value val on the specified Prolog stream. For exampleWrite(val, tag, stream)
are two ways how to print a Prolog integer number; the output looks likeFprintf(Current_Output, "tag = %d, value = %d\n", tag.kernel, val.nint); Write(val, tag, Current_Output);
footnote Be aware that you can not rely on a specific coding of a ECLiPSe tag! Similarly, the macrotag = 5, value = 1 1
has the effect of writeq/2.Writeq(val, tag, stream)