Skip to main content
Solved

ZPL/ INPUT numeric value to string

  • May 17, 2022
  • 1 reply
  • 894 views

Forum|alt.badge.img

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).

1 reply

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 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).