Boolean Return With Loop Checking

WolfieeifloW

WEHZ Helper
Reaction score
372
EDIT: Nevermind, forgot to initialize the COLORS array :banghead: .

JASS:
private function CheckColor takes string Col returns boolean
    local integer i = 0
    local boolean cc = false
        
    loop
    exitwhen i == COLORSNUM
        if (Col != COLORS<i>) then
            set cc = false
        else
            return true
        endif
        set i = i + 1
    endloop
    return cc    
    //if (Col != &quot;red&quot; and Col != &quot;gold&quot; and Col != &quot;cyan&quot; and Col != &quot;blue&quot; and Col != &quot;brown&quot; and Col != &quot;grey&quot; and Col != &quot;gray&quot; and Col != &quot;green&quot; and Col != &quot;orange&quot; and Col != &quot;pink&quot;) then
        //return false
    //else
        //return true
    //endif
endfunction</i>

It always returns false.
Commented section left in to show what I'm trying to do (It's what I originally had) .
 

Romek

Super Moderator
Reaction score
964
JASS:
private function CheckColor takes string Col returns boolean
    local integer i = 0
    loop
        exitwhen i == COLORSNUM
        if Col == COLORS<i> then
            return true
        endif
        set i = i + 1
    endloop
    return false    
endfunction</i>

You may also want to use StringCase, so that "ReD" == "rEd".
Make both the COLORS and Col small. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top