Warcraft III resources & community, 2003–2006 · archived

StringIsHexadecimal

not rated
Submitted by vjeuxText Parsing0 downloads
Return true if the string contain only a~f, A~F and 0~9

Ex : StringIsHexadecimal("FF00Cc") == true
StringIsHexadecimal("00FF00GG") == false

Source

function StringIsHexadecimal takes string source returns boolean
local string list = "abcdefABCDEF1234567890"
local integer i = 1
local integer k = 1
local boolean b = false
local integer x
    set x = StringLength(source)
    loop
        exitwhen (i == x)
        set k = 1
        set b = false
        loop
            exitwhen (k == 22)
            if SubString(source,i,i+1) == SubString(list,k,k+1) then
                set b = true
                exitwhen true
            endif
            set k = k + 1
        endloop
        if b == false then
            return false
        endif
        set i = i + 1
    endloop
    
    return true
endfunction

Comments

0

No comments.