I have made a first success in my life to use tmp_file_stream/3
.
In fact, I failed to use tmp_file/2
some time long ago due to some reason on my side.
From now on, it is not necessary to worry about working directories for putting temporary files.
Thanks SWI-Prolog.
%! show_cla(+Cla) is det.
% View classification Cla in graphics using dot.
% ?- show_cla(cla([a,b],[1,2], [1-[a], 2-[b]])).
% ?- show_cla(cla([a,b],[1,2], [1-[a,b], 2-[b]])).
% ?- show_cla(cla([1],[a], [a-[1]])).
% ?- show_cla(cla([1,2],[a], [a-[1,2]])).
show_cla(Cla):- cla_to_dot(Cla, DotStr),
T = pdf,
tmp_file_stream(DOT, F0, [encoding(utf8), extension(dot)]),
close(F0),
tmp_file_stream(PDF, F1, [encoding(utf8), extension(pdf)]),
close(F1),
file(DOT, write, write(DotStr)),
pshell(dot(-'T'(T), -o(PDF), DOT); open(PDF)).
% old_show_cla(Cla):- cla_to_dot(Cla, DotStr),
% T = pdf,
% expand_file_name("~/tmp/TEMP.dot", [DOT]),
% expand_file_name("~/tmp/TEMP.pdf", [PDF]),
% file(DOT, write, write(DotStr)),
% pshell(dot(-'T'(T), -o(PDF), DOT); open(PDF)).