cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert string to value

How I can convert string variable (for example "10.1") to value?

Thanks in advance
3 Replies 3
Anonymous
Not applicable
Tsepov wrote:
How I can convert string variable (for example "10.1") to value?

Thanks in advance
SPLIT (string, format, variable1 [, variable2, ..., variablen])

The string expression to numeric with using "% n"
A bit tricky...

I have real life example from the library I have made some time ago...

They had the types of the object defined with numbers (so had to be strings)
And for some reason I had to get those numbers...
VALUES "TYP" 	"E 104500", "E 104510", "E 104520"  (and so on)

NN=SPLIT (TYP, "%s %n", TYP_L, TYP_NUM)

TYP_NUM6=(TYP_NUM-(TYP_NUM MOD 100000))/100000
TYP_NUM5=(TYP_NUM-(TYP_NUM MOD 10000))/10000- TYP_NUM6*10
TYP_NUM4=(TYP_NUM-(TYP_NUM MOD 1000))/1000- TYP_NUM6*100- TYP_NUM5*10
TYP_NUM3=(TYP_NUM-(TYP_NUM MOD 100))/100- TYP_NUM6*1000- TYP_NUM5*100- TYP_NUM4*10
TYP_NUM2=(TYP_NUM-(TYP_NUM MOD 10))/10- TYP_NUM6*10000- TYP_NUM5*1000- TYP_NUM4*100 - TYP_NUM3*10
TYP_NUM1=TYP_NUM MOD 10
Best Regards,
Piotr
Anonymous
Not applicable
Thank you very much!
It works!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!