Operands may be used as dependent variables in Universal Plots. However, there are some cases where I use a ZPLM and the plot shows a straight line of constant value, instead of the curve I expect to see.
A ZPLM may be used as the dependent variable in a Universal Plot. However, the ZPLM must not include any macro commands which manipulate the current lens setup. Examples include GETT() and CLOSEWINDOW. This is briefly discussed in the Help System file 'The Optimize Tab (sequential ui mode) > Optimization Overview > User Defined Operands (optimization overview) > Changes Made to the Lens from within the ZPLM Marcro ':
While there are some instances where GETT may appear to work in a ZPLM for the currently-opened file, it will not be useful for optimization or for the Universal Plots. This is because the Universal Plot and optimization algorithm both rely on using temporary copies of the current lens file to make updates and report the results. As is stated in the Help System file above, GETT (and similar operands) will not be updated with these temporary files.
Luckily, the GETTEXTFILE keyword will work properly in this instance! As an example, let's say we want to pull a value from the Footprint Diagram and report it as the output of the ZPLM. In this case, I want to report the 'Ray Y Maximum':
The macro below will use GETTEXTFILE to extract the data and output it as the Data = 0 result for the ZPLM:
! Get a temporary file name
A$ = $TEMPFILENAME()
! Compute the data and place in the temp file
GETTEXTFILE A$, Foo
! Open the new file
OPEN A$
! Skip the first lines
FOR i, 1, 11, 1
READSTRING B$
NEXT
! Read the value and convert to number
FORMAT 1.10
READSTRING Max$
val$ = $RIGHTSTRING(Max$, 12)
val = SVAL(val$)
CLOSE
OPTRETURN 0,val
! Clean up by deleting the temporary file
DELETEFILE A$
We see that the ZPLM reports the correct value:
Additionally, when this ZPLM is used in the Universal Plot, we see that it updates as expected. I am attaching a sample file as an example.
Naturally, this type of analysis could take a bit longer to calculate as the temporary file must be created and deleted in each cycle. As such, if you are more interested in plotting than optimizing for the time-being, you could try using the PLOT keyword instead of the Universal Plot feature. You can find some guidance on how to use that here: 'How to use the PLOT keyword in ZPL.'
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.