Hello Community,
I would like to write a macro which can create a file and record the changes on the models. However, I can't create a file with the method Context.createOutputObject since it's a report function.
I would like to ask is there any method to create a file within the macro?
Thanks in advance!
Hi there,
as far as I can tell ArisScript itself does not offer any methods to create a file on the client.
However you are not restricted to only using ArisScript - you could use standard Java instead. Granted, I only managed to create a .txt file and write a single word into it - most likely you can find a more impressive way to do things.
var file = new java.io.File(Context.getSelectedOutputPath() + "\\" + Context.getSelectedOutputFile()); var writer = new java.io.FileWriter(file); writer.write("test"); writer.close(); Context.executeFile(file.toPath()) //executeFile is the ArisScrip way to display files you created
Just don't forget to write the entire class path of a Java class whenever you're using one (so instead of "import java.io.File;" + "File(...);" just write "java.io.File(...);").