Is it possible to reassign the logStream variable as above, to arbitrary number of many different log files,
in the same VP8 project?
e.g. log.txt, log1.txt, code1.ada, code2.vhdl, etc.
I have the impression that VP8 forbides this. Is it true?
Discussions related to Visual Prolog
The code below works as expected. It would be good practice to keep track of the output streams which need to be closed when you are finished so I put it a rudimentary way of doing that, too.
Code: Select all
class facts logStream : outputStream := erroneous. logStreamsToClose : outputStream* := . class predicates testlog : (). clauses testlog() :- logStream := outputStream_file::create("File1.txt"), logStreamsToClose := [logStream | logStreamsToClose], logStream:write("Some text to stream 1"), logStream := outputStream_file::create("File2.txt"), logStreamsToClose := [logStream | logStreamsToClose], logStream:write("Different text to stream 2"), foreach OS in logStreamsToClose do try OS:close() catch Err do stdio::write("\nError #", Err, " closing stream") end try end foreach.