Joining string and number in Zemax Macro

  • 9 December 2019
  • 2 replies
  • 151 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

Userlevel 3
Badge +1
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



 


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

Reply