If the stream is not a file, the Name argument has different meanings: If it is the user's console, the pseudo file names 'user' or 'error' are returned. If the stream is a string stream, Name returns the current contents of the string stream.
The following table illustrates the predefined symbolic system streams with the name, mode, and initial physical stream number that they are initially assigned to.
Logical Name Mode Number input user read 0 stdin user read 0 output user write 1 stdout user write 1 warning_output user write 1 log_output user write 1 error error write 2 stderr error write 2 null null update 3
Also see set_stream/2 for details on how to assign a symbolic stream name to a physical stream, or to redirect a symbolic stream name.
Success: current_stream(Name,Mode,Stream). % returns all % open streams. [eclipse]: current_stream(error,Mode,Stream). Mode = write Stream = 2 More? (;) yes. [eclipse]: open(file,update,s), current_stream(file,M,s). M = update yes. [eclipse]: open(F,string(10),f), writeln(f, "bigstring"), > current_stream(Data,M,f). F = "bigstring\n" Data = "bigstring\n" M = string yes. Fail: open(file,update,f), current_stream("file",M,f). current_stream(X,no,Y). Error: current_stream(12,Mode,String). (Error 5).