1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

String functions

Discussion in 'Graveyard' started by maskedpoptart, Jun 24, 2009.

  1. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2

    Haven't tested it but are you sure it's limitted to 1 or four? I'd say 1 to 4...
     
  2. busterkomo

    busterkomo

    Joined:
    Jun 17, 2007
    Messages:
    1,423
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    It's 1 or 4. Both 2 and 3 will produce compile errors.
     
  3. maskedpoptart

    maskedpoptart

    Joined:
    Aug 4, 2006
    Messages:
    351
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Hey guys, I am back from my trip. aznricepuff, I have done everything you asked since initial release. At the moment, I am not aware of any reason this resource should not be approved. It is quite useful and has no bugs that I am aware of. I would appreciate it if you could either approve it, tell me what I can do to get it approved, or tell me why it should not be approved. Thanks again.
     
  4. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Yea, sorry about the delay. I've been busy with other things (non-wc or HW related) lately.

    Approved.
     
  5. maskedpoptart

    maskedpoptart

    Joined:
    Aug 4, 2006
    Messages:
    351
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Thank you mr. rice puff :grin:. I want to eat you up (jk).

    P.S. I completely understand. Don't worry about the delay.
     
  6. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    Please submit this on Wc3c so I can use it in my submissions there :D
     
  7. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,015
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    library String

    This is a totally unacceptable name for a library which deals so extremely little with strings in general. Should be more like "PlayerColorString" but its usefulness is arguable compared to the PlayerColorString library in the JASS Functions forum.
     
  8. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,015
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Graveyarded.
     
  9. 3ICE

    3ICE

    Joined:
    Jul 4, 2007
    Messages:
    64
    Resources:
    0
    Resources:
    0
    (Hope bumping stuff in the graveyard forum is a non-issue.)
    Thank you for making this! It was super helpful to me, as a base for my much simpler RemoveNewlines snippet:
    Code (vJASS):
    function RemoveNewlines takes string s returns string
        local integer i = 0
        local integer l = StringLength(s)
        if(2 > l)then
            return s
        endif
        loop
            exitwhen i+2 > l
            if(SubString(s, i, i+2) == "|n")then
                if(i+2 <= l)then
                    set s = SubString(s, 0, i)+SubString(s, i+2, l)
                else
                    set s = SubString(s, 0, i)
                endif
                set i = i - 2
            endif
            set i = i + 1
        endloop
        return s
    endfunction

    I googled "war3 stringreplace HIVE" and found this graveyarded project. Still useful! Thanks.

    Edit: Fewer safety checks version:
    Code (vJASS):
    function RemoveNewLines takes string s returns string
        local integer i = 0
        local integer l = StringLength(s)
        loop
            exitwhen i+2 > l
            if(SubString(s, i, i+2) == "|n")then
                if(i+2 <= l)then
                    set s = SubString(s, 0, i)+SubString(s, i+2, l)
                endif
                set i = i - 2
            endif
            set i = i + 1
        endloop
        return s
    endfunction


    I'm using:
    Code (vJASS):
    function RemoveNewLine takes string s returns string
        local integer i = 0
        local integer l = StringLength(s)
        loop
            exitwhen i+2 > l
            if(SubString(s, i, i+2) == "|n")then
                return SubString(s, 0, i)+" "+SubString(s, i+2, l)
            endif
            set i = i + 1
        endloop
        return s
    endfunction
     
    Because there's only ever one newline in my use case.
     
    Last edited: Aug 19, 2019