Warcraft III resources & community, 2003–2006 · archived

StringRepeat

not rated
Submitted by PepparText Parsing0 downloads
Repeats whichString times times. Fast. Will crash the game or cause undesirable results if length of whichString * times is larger than 2048.

Example:
StringRepeat("JASS", 5) = "JASSJASSJASSJASSJASS"

Source

function StringRepeat takes string whichString, integer times returns string
    local string s = whichString
    local string o = ""
    local integer i = times
    if i < 0 then
        return null
    endif
    loop
        if i / 2 * 2 != i then
            set o = o + s
        endif
        set i = i / 2
        exitwhen i == 0
        set s = s + s
    endloop
    return o
endfunction

Comments

0

No comments.