Skip to main content
Solved

concatenate string and variable in ZPL

  • September 17, 2021
  • 1 reply
  • 701 views

John.Hygelund
Fully Spectral
Forum|alt.badge.img+1

Regarding the SETVAR ZLP keyword, want to use a variable to define the ‘Pn for parameter n’. I need to concatenate “P” with my index variable i. How do I accomplish this?

Thank you,

John 

Best answer by Csilla Timar-Fulep

Hi John,

Thanks for you question here on the forums.

You may use the following ZPL macro syntax, where param and surf are integers:

code$ = "P" + $STR(param)
SETVAR surf, code$, 1

For more details about how to use strings in the ZPL macro language, please check out this knowledgebase article:
Working with strings in ZPL Macros – Knowledgebase (zemax.com)

Best,
Csilla

1 reply

Csilla Timar-Fulep
Zemax Staff
Forum|alt.badge.img+2

Hi John,

Thanks for you question here on the forums.

You may use the following ZPL macro syntax, where param and surf are integers:

code$ = "P" + $STR(param)
SETVAR surf, code$, 1

For more details about how to use strings in the ZPL macro language, please check out this knowledgebase article:
Working with strings in ZPL Macros – Knowledgebase (zemax.com)

Best,
Csilla