# Thread: Values to use in calculations

1. ## Values to use in calculations

Hi all,

I'm a new WinRunner user and I'm trying to use values that i get from a web page (edit_get_text) for some calculations. My problem is that the value that i get from the web page has a dollar sign infront of it and is in quotes "\$xxx.xx". I can't use it for arithmetic calculations in it's present form.
How do i get just the number and nothing else ??

------------------

2. ## Re: Values to use in calculations

These two functions should help.

------------------

3. ## Re: Values to use in calculations

Thanks !!

------------------

4. ## Re: Values to use in calculations

A better function than suggested

function get_number(in orgvalue,out modvalue)
{
auto len = 0;
auto Cr ;
auto i;
len = length(orgvalue);
modvalue = "";

for (i = 1; i &lt;= len;i++)
{
Cr = substr(orgvalue,i,1);
if (ascii(Cr) == 48 &#0124; &#0124; ascii(Cr) == 49 &#0124; &#0124;
ascii(Cr) == 50 &#0124; &#0124; ascii(Cr) == 51 &#0124; &#0124;
ascii(Cr) == 52 &#0124; &#0124; ascii(Cr) == 53 &#0124; &#0124;
ascii(Cr) == 54 &#0124; &#0124; ascii(Cr) == 55 &#0124; &#0124;
ascii(Cr) == 56 &#0124; &#0124; ascii(Cr) == 57 &#0124; &#0124;
ascii(Cr) == 46)

modvalue = modvalue & Cr ;
}

}

Try above function. This takes care of any character except "."

------------------

5. ## Re: Values to use in calculations

Just to throw my hat in the ring, here is what I use:
------------------
Charles Reace
charlesDOTreaceATverizonDOTnet

"Any sufficiently advanced bug is indistinguishable from a feature." -Bruce Brown

6. ## Re: Values to use in calculations

Thanks for "ALL" the help.

------------------

7. ## Re: Values to use in calculations

Charles R,

I am trying to use your solution but i can't seem to get it to work. How do I feed an input string into your routine and then how do I get the result ??
I've tried a few ideas but haven't been successful

------------------

8. ## Re: Values to use in calculations

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by cdninus:
Charles R,

I am trying to use your solution but i can't seem to get it to work. How do I feed an input string into your routine and then how do I get the result ??
I've tried a few ideas but haven't been successful

<HR></BLOCKQUOTE>

Either:

myNumber = make_numeric(someString);

or:

make_numeric(someString, myNumber);

Also, I've found that if you cut and paste from the web page, new-lines may get lost. I'm attaching a .txt file with my code in case that helps.

------------------
Charles Reace
charlesDOTreaceATverizonDOTnet

"Any sufficiently advanced bug is indistinguishable from a feature." -Bruce Brown

9. ## Re: Values to use in calculations

Charles R,

Thanks for all your help. I've been struggling with this for quite a while and now everything is working well.

------------------

10. ## Re: Values to use in calculations

This poor guy admitted that he's new in WinRunner and is trying to get values that has a dollar sign at the beinging of the number and double quote at the begingin and end of the string.

I saw few replies going back and forth and as another novice I got scared too. As the problem described can't we simply solve it by using substr() and length() for this instance? I mean, I have no doubt that people are using their knowledge and skills to work around different kinds of critical and complex issues, but I don't think this needed all those codes??

Please pardon my limited knowledge, but I got scared looking at those codes.

------------------
-------------------
Sakkaf Alam

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.