Skip to main content
Solved

ZPL/ INPUT numeric value to string

  • May 17, 2022
  • 1 reply
  • 802 views

  • Ultraviolet
  • 29 replies

How does one convert the numeric value obtained from user INPUT to STRING data type?

Thanks

Best answer by MichaelH

Hi Asuku,

To convert a value to a string, you should use $STR(val).  This will use the currently defined FORMAT keyword, so if you want to convert to an integer, double, or scientific notation, you will need to use the FORMAT before $STR(val).

Likewise, if you want to convert a string to a numeric value, you can use either SVAL(str$) or LVAL(str$) (SVAL will use a period as a decimal separator while LVAL will use the locally defined character as the decimal separator).

View original
Did this topic help you find an answer to your question?

1 reply

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 365 replies
  • Answer
  • May 17, 2022

Hi Asuku,

To convert a value to a string, you should use $STR(val).  This will use the currently defined FORMAT keyword, so if you want to convert to an integer, double, or scientific notation, you will need to use the FORMAT before $STR(val).

Likewise, if you want to convert a string to a numeric value, you can use either SVAL(str$) or LVAL(str$) (SVAL will use a period as a decimal separator while LVAL will use the locally defined character as the decimal separator).


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