Sometimes a macro needs to open series of sequentially-named files such as the saved Monte Carlo files. In the case of the saved Monte Carlo files, they are named from MC_T0001.zmx, MC_T0002.zmx to MC_T9999.zmx. The included code snippet changes the value of the myfiles_name$ string variable in the macro such that it contains the proper path and file name of the saved Monte Carlo file in each execution of the FOR loop.

To see the macro, download it from the last page of this article, place it in the {root ZEMAX}Macros directory and open it with any text editor.



The macro is written so that the values of the myfile_name$ is only printed instead of opening the files with those names. When incorporating this code into your own program, replace the PRINT keyword with the LOADLENS keywords to open the lens files instead.

Upon execution of the included macro, you will get the following output window that shows the content of the string variable.