PDA

View Full Version : Parse Numeric string in Number



Lancill
03-05-2003, 08:36 AM
I need to parse a numeric string in a number!! How can I do?
Ex:
STRING: "5,16"
Number (I need to use it to calculate other numbers!): 5,16

Thx /ubbthreads/images/icons/smile.gif

Worm
03-05-2003, 09:09 AM
Not sure what your asking here, but take a look at the String.GetDelimitedString action. It works like this:

%SecondNumber% = String.GetDelimitedString ("5,16", 1)

%SecondNumber% would equal 16

Lancill
03-05-2003, 09:24 AM
no... I have a numeric string!
example:
NUMERIC STRING: "16"
I need to sum 2 to 16! But if I sum
"16"+2 = "162"!! (Sum of string)
I want to convert the string "16" to a number 16 so the sum 16+2 = 18! (Sum of number)
It's like Integer.parse("162") in JAVA!!

Worm
03-05-2003, 09:29 AM
AMS doesn't really have a variable type. Simply use the evaluate function (check box below the text box) in the Set Variable actions

%SUM% = Evaluate (16 + 2)

Lorne
03-05-2003, 09:32 AM
"16" + "2" will result in 18. There is no difference between numeric strings and numbers in AutoPlay.

In fact, everything's a string internally, and it gets interpreted as a number/version/string at run time. All that matters is the operator you use.

Note that if you try to add a number to a string, or add two numbers that aren't entirely numeric (like "16" + "2a" or something), then the values will be interpreted as strings.

What is it you're trying to do, exactly?

Worm
03-05-2003, 09:32 AM
You can use variables in the expression too...

%Num1% = "16"
%Num2% = "2"
%Sum1% = Evaluate (%Num1% + %Num2%)
%Sum2% = Evaluate (16 + 2)

Lancill
03-05-2003, 07:21 PM
That's all right, it was a stupid problem: I had in input number like 5,16 or 7,00 etc...
the "," can't be used in the number format (it need "."), so AMS viewed it as string!

Thx again! /ubbthreads/images/icons/smile.gif