How to create a sub program to read data from excel in ZPL?Does zemax have this function?
read data from excel
Best answer by David.Nguyen
Accessing external files in ZPL is limited to text files with a specific format. If we take the READ
keyword for example, this is an excerpt of the Help File:
The file must be already open, see the keyword OPEN for details. Each READ command reads a single line from the file. The first valid data field from this line is placed in the variable first listed. The data from the second field is placed in the second variable listed, if any.
Therefore, the number of variables listed in the read command should match the number of columns in the text file. Numeric data in the file should be delimited by spaces.
The data may be in free-form, and is internally promoted to double precision. In order to use decimal separator currently selected in Windows settings use READ_LOCALE keyword. A maximum of 2000 characters can be read in on any single line. The maximum number of variable arguments is 199; for reading longer lines with more arguments use READNEXT instead. The variables listed must be valid ZPL variable names.
You could easily save your Excel file as a comma-separated value file (*.CSV), but since the format for ZPL should be that: numeric data in the file should be delimited by spaces. I am not sure if it will work :( let us know if you test this.
Another option is to use the ZOS-API to have a direct connection between OpticStudio and Excel as described by
I hope this helps.
Take care,
David
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.