Thanks:  0
Likes:  0
Dislikes:  0

1. ## stuff function

I am trying to use verify to compare to numbers ,one out of which has five zeros after decimal places. The numbers are same but as they are strings it gives an error when you compare it using verify. So I thought I will add some zeros in the string with a lower length
here is the code,,

[-] void RoundingOff (string x,string y)
[ ] integer count
[ ] x = "123"
[ ] y="123.00000"
[-] if (len(x)&lt;len(y))
[ ] x= Stuff(x,len(x),0,".")
[-] for (count = Len(x); count&lt;len(y); count ++)
[ ] x=Stuff(x,len(x),0,"0")
[-] else
[-] if(len(y)&lt;len(x))
[ ] y=Stuff(y,len(y),0,".")
[-] for (count = len(y); count&lt;len(x); count ++)
[ ] y=Stuff(y,len(y),0,"0")
[-] if (x!=NULL)&&(y!=NULL)
[ ] verify(Trim(x),Trim(y))

The error I am getting is the with the Stuff function. It is not adding the decimal point at the right position no matter what.

------------------
Yukte Oberoi

[This message has been edited by yuktioberoi (edited 10-24-2002).]

2. ## Re: stuff function

instead of using the Stuff function, why don't you just use Val(). So for example:

Verify(Val(x),Val(y))

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

3. ## Re: stuff function

Do a type cast or get the numbers as float(with or without decimals).

float i = 123
float j = 123.00000

// to convert i to be similar to j and to // either print it or store to string

Printf(".5f", i)

------------------
"WE CANNOT REDUCE COMPLEXITY; WE CAN ONLY CREATE THE
ILLUSION OF SIMPLICITY."

4. ## Re: stuff function

Thanks a ton,,TonyM it works perfect ..
But I still have this stuff in my mind.. why does it not work ..

------------------
Yukte Oberoi

[This message has been edited by yuktioberoi (edited 10-24-2002).]

5. ## Re: stuff function

Thanks gram..its surely very useful piece of code..

------------------
Yukte Oberoi

6. ## Re: stuff function

Stuff wants to insert it at Len of x instead of appending it to the string.

the following mod to your code works
------------------
stepping through the code thru debugger will help to understand why.

[This message has been edited by TonyM (edited 10-24-2002).]

7. ## Re: stuff function

hey TonyM, Thanks

------------------
Yukte Oberoi

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.