I would like to create a new text file from inside of a ZPL macro for saving data while the macro runs. I see the OPEN command, but it requires the file to already be created. I do not see any keyword for creating the new file. Is there a way to create new files from inside of a running Macro?
Thank you for contacting Zemax support!
Usually there are two ways to save a text file using ZPL macro. One is through the keyword GETTEXTFILE. The keyword uses following syntax and allows you to create a new text file that saves the information from the Text tab from any OpticStudio analysis window that supports text.
The second way is to use keyword OUTPUT. The OUTPUT keyword specifies a destination for text output generated by subsequent PRINT command. Output is either to the screen, or to a file. If OUTPUT SCREEN is specified alone, then all subsequently executed PRINT commands will be directed to the screen. If a valid filename is provided, then subsequent PRINT commands will output to the filename specified. If a filename with no path is provided, output will be directed to the \Macros folder. The syntax is shown below.
If you would like to know more on how to use the keyword, you can find it explained in the Help File at The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > OUTPUT
Let us know if these methods work for you or if you have any other questions.