What's the idiomatic way to create temporary files in mosel?

37 Views Asked by At

I'm looking for something similar to the tempfile functions in R/Python: https://docs.python.org/3/library/tempfile.html https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/tempfile

Does this exist in Mosel?

1

There are 1 best solutions below

0
On

You could use the I/O driver "tmp:" to create a file in the temporary directory of the Mosel instance, possibly in combination with the function "newmuid" to create a unique identifer as filename, so for example:

tmpfname:="tmp:"+newmuid
fopen(tmpfname, F_OUTPUT)
writeln("This line is written into the temporary file")
fclose(F_OUTPUT)