ZPL: Error in ModifySettings

  • 4 February 2020
  • 2 replies
  • 441 views

I am creating a macro to change parameters in the analysis tools but when I run the code I get the following error:



ERROR in MODIFYSETTINGS: Incorrect version number in settings file.  



Prior to running the macro I saved the .cfg in the lens file directory.  I have deleted all the .CFG files in the global and local (lens) directories but am still getting this error.  How do I clear the Modifiy settings and update to the correct version number?



On my computer I have Optic Studio 19.8 and 17.5 installed.  Would it be useful to uninstall 17.5?

2 replies

I have the same issue using this command "MODIFYSETTINGS settings$, HPS_FIELD, 1" i get the same error as R. Sims. When I use "MODIFYSETTINGS settings$, PSF_FIELD, 1" it works just fine. 



I am running Optic Studios Professional 19.8.
Userlevel 6
Badge +2

Hi Robert and Patrice!



This error usually appears when the incorrect settings file is used with the MODIFYSETTINGS keyword.



Typically, there are two configuration files you can look to when using MODIFYSETTINGS for a particular analysis window. Let's use a Huygen's PSF (found under Analyze…PSF…Huygen's PSF) as an example. When I save the settings for this window, two configuration files are generated: HPS.CFG and Lens_File_Name.CFG. The HPS.CFG file will appear in the {Zemax}\Configs folder while the other will appear in the same folder as the lens file you're working in. For example, if I saved the Huygen's PSF of the "Cooke 40 degree field.zmx" sample file, then a file titled "Cooke 40 degree field.CFG" would appear in the {Zemax}\Samples\Sequential\Objectives folder.



By default, the lens-specific configuration file will take precedence over the other. Our HPS.CFG file will be used for any other lens files that do not have an individual configuration saved.



When we use MODIFYSETTINGS, then, we must make sure we point to the correct configuration file. If I have a lens-specific CFG, then I will use the code below:

 


path$ = "C:\Documents\Zemax\Samples\Sequential\Objectives\"
file$ = "Cooke 40 degree field.CFG"
filename$ = path$ + file$
MODIFYSETTINGS filename$, HPS_FIELD, 3
PRINT "Done"



If I do not have a lens-specific CFG, then I will use this code instead:

 


path$ = "C:\Documents\Zemax\Configs\"
file$ = "HPS.CFG"
filename$ = path$ + file$
MODIFYSETTINGS filename$, HPS_FIELD, 3
PRINT "Done"



If OpticStudio can't find the settings file specified by "filename$", then we will see the "Incorrect version number in settings file" error. We will also see that error if the setting I am trying to change cannot be found. For example, if I tried to change the FFT PSF instead of the Huygen's, then I need to update the configuration file to "FPS.CFG" and the command I'm using to "PSF_FIELD". See below:



path$ = "C:\Documents\Zemax\Configs\"
file$ = "FPS.CFG"
filename$ = path$ + file$
MODIFYSETTINGS filename$, PSF_FIELD, 3
PRINT "Done"



If I tried to use "HPS_FIELD" while editing the "FPS.CFG", then I would see the same error.



Robert, when you say you deleted all CFG files, did you save a new one before running the macro? If you did, did you update the settings file name in your code? 



Patrice, when you say that the line of code worked for "PSF_FIELD" but not for "HPS_FIELD", did you make sure to update "settings$" so that it matched the correct CFG file?  


Reply