Skip to main content

Joining string and number in Zemax Macro

  • December 9, 2019
  • 2 replies
  • 247 views

Dear all,

I am a beginner of zpl and I want to make names of files with the 'for' loop.
For example,

   file1.txt
   file2.txt
   file3.txt
   ...
   fileN.txt

Can I add a number to a string?
What shall I do to make "filename" + number(integer)  + ".txt" ?
Is there any smart method to do this?  

Thanks in advance

2 replies

Sean Turner
Fully Spectral
Forum|alt.badge.img+1
  • Fully Spectral
  • 106 replies
  • December 9, 2019
The $STR() function is what you need. I generally iterate for loops with 'i' or 'j' as the variable, so my loop would look something like this:

FOR i, 0, n, 1
FILENAME$ = "FILE" + $STR(i) + ".TXT"
NEXT

 

  • Infrared
  • 22 replies
  • November 26, 2020

Hello all,

 

I am trying to save the data with different file name using Macro, but not able to save my data with a different name. Data is saving with same name. Can anyone please help?

I am using the for loop and saving the text window using the for loop

for i,1,2,1
SAVEWINDOW 2, 'E:\faheem....\Textfile name(i)
end

The text file should very with 'i' value.

Best and regards,
Faheem