SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stuff; problem inserting at the end of a string--Bug?

    I have "05" I want to append "[1]"

    Can stuff make it "05[1]"???

    Stuff("05",2,0,"[1])
    Stuff("05",3,0,"[1])
    ...
    All give me "0[1]5"

    Stuff("{"05"} ",3,0,"[1])
    adding a space will let me get "05[1]"

    is that how Stuff works?? Why is it not possible to insert at the end of a string without modifying the original string??

    Is this a bug or what?

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

  2. #2
    Member
    Join Date
    Jun 2001
    Location
    Berkeley, CA, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    It appears Stuff always inserts into a string, and cannot be used for appending to the end of a string.

    When I added a space to the end of the statement, I got the following output:

    *05[1] *

    While it appears that Stuff appends in that situation, it actually has moved the space to the last character.

    I think it might be a bug in the Stuff routine. Appending to the beginning of a string looks to be working correctly.

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


    [This message has been edited by Bruce Cummins (edited 06-25-2001).]

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    Good point about the ending space, it's not helping just printing the string, cuz a space is invisible:P Stuff() is still doing the same thing as before even though when I added a space, so we have to use trim() to get rid of the space

    newStuff(orig,i,j,new)
    if(i>=len(orig))
    return strim(stuff("{orig} ",i,j,new)))
    else
    stuff(orig,i,j,new)

    //for mean ppl you can also handle case where you could append when i>Len(orig). The result would be the orig+spaces+new.




    [This message has been edited by GodKnows (edited 06-25-2001).]

  4. #4
    Junior Member
    Join Date
    Jan 2001
    Location
    New York, NY, USA
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    Deleted.

    [This message has been edited by gsczepura (edited 06-25-2001).]

  5. #5
    Member
    Join Date
    Jun 2001
    Location
    Berkeley, CA, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    Is there a particular reason you're using Stuff to do the string append?

    STRING sTest = "05"
    STRING sTest2 = "[01]"

    sTest += sTest2
    sTest = "{sTest}{sTest2}"

    Both formulas give the answer you want.




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

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    No. I don't use it personally. I just find the problem quiet interesting. It might help others.



    [This message has been edited by GodKnows (edited 06-25-2001).]

  7. #7
    Senior Member
    Join Date
    Aug 1999
    Location
    San Diego, CA USA
    Posts
    219
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    The simple answers are the ones Bruce Cummings mentioned as well as

    sTest = sTest + sTest2

    In this case the + is the concatenation (not addition) operator.

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

  8. #8
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff; problem inserting at the end of a string--Bug?

    you can stuff at the beginning but not the end, so flip flop the sOrig and the sReplace.

    print(Stuff("[1]", 1, 0, "05"))
    prints 05[1]

    I'm ashamed of myself for replying to this post.

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

 

 

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 08:54 AM.

Copyright BetaSoft Inc.