Skip to main content

Joining string and number in Zemax Macro

  • December 9, 2019
  • 2 replies
  • 216 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
Did this topic help you find an answer to your question?

Sean Turner
Ultraviolet
Forum|alt.badge.img+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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings