SPONSORS:






User Tag List

Results 1 to 7 of 7

Thread: stuff function

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Location
    Rochester
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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)<len(y))
    [ ] x= Stuff(x,len(x),0,".")
    [-] for (count = Len(x); count<len(y); count ++)
    [ ] x=Stuff(x,len(x),0,"0")
    [-] else
    [-] if(len(y)<len(x))
    [ ] y=Stuff(y,len(y),0,".")
    [-] for (count = len(y); count<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.

    HELP please..!!!!!!!

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

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

  2. #2
    Senior Member
    Join Date
    Nov 1999
    Location
    Eagle, ID,USA
    Posts
    1,035
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: stuff function

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

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

    ------------------
    Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac.

  3. #3
    Senior Member
    Join Date
    Oct 2001
    Location
    NC, United States
    Posts
    148
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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."
    - Grady Booch
    -gram

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Location
    Rochester
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: stuff function

    Thanks a ton,,TonyM it works perfect ..
    But I still have this stuff in my mind.. why does it not work ..
    and I will keep thinking about it till I get a solution.. so please help..still

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

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

  5. #5
    Junior Member
    Join Date
    Sep 2002
    Location
    Rochester
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: stuff function

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

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

  6. #6
    Senior Member
    Join Date
    Nov 1999
    Location
    Eagle, ID,USA
    Posts
    1,035
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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).]
    Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac.

  7. #7
    Junior Member
    Join Date
    Sep 2002
    Location
    Rochester
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: stuff function

    hey TonyM, Thanks

    ------------------
    Yukte Oberoi
    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
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:15 PM.

Copyright BetaSoft Inc.