Page 1 of 1

Can't decide how to pass an handler

Posted: Sat Nov 15, 2014 10:24 am
by AstghikM
Hi evrybody :) i have one problem...

Code: Select all

global player1,player2,whoIs,check

on openCard
     repeat with i=1 to 5
        repeat with j=1 to 5
              put  the text of field("p"&i&j) into check[i][j]
        end repeat
     end repeat
          checkIfwin
        --send openCard to me in 1 secs
end openCard

command checkIfwin
   
   put 1 into verticalK
       repeat with i=1 to 5
           repeat with j=1 to 5
              if j<5 then
                 if check[i][j]=check[i][j+1] then
                    put verticalK+1 into verticalK
                    if verticalK is 5 then
                     
                       answer verticalK
                       pass checkIfwin
                       end if
                 end if
              else
                  if verticalK is 5 then
                   
                     answer verticalK
                      pass checkIfwin
                     else
                 put 1 into verticalK
                 end if
              end if
           end repeat
        end repeat
  
end checkIfwin

 
here is two handlers one is OpenCard and the other one is command checkIfwin :) so i'm sending OpenCard to me every 1 seconds, but when verticalK is 5 (let's say you win) i want to pass checkIfwin handler, but after all that in openCard handler i get an error: no such handler(it is about checkIfwin). how to pass OpenCard too when verticalK is 5? :D i hope i could explain my problem :D

Re: Can't decide how to pass an handler

Posted: Sat Nov 15, 2014 11:11 am
by AstghikM
i will wait for your answer, i have been try many ways but no result :oops:

Re: Can't decide how to pass an handler

Posted: Sat Nov 15, 2014 12:30 pm
by Klaus
Hi AstghikM,

not sure, but maybe you mean EXIT?
That will leave the current handler:

Code: Select all

...
if verticalK = 5 then
   answer verticalK
   EXIT checkIfwin
end if
...
Best

Klaus

Re: Can't decide how to pass an handler

Posted: Mon Nov 17, 2014 8:09 am
by AstghikM
Klaus wrote:Hi AstghikM,

not sure, but maybe you mean EXIT?
That will leave the current handler:

Code: Select all

...
if verticalK = 5 then
   answer verticalK
   EXIT checkIfwin
end if
...
Best

Klaus
Thank you :) it works for me :) i didn't know that i can just exit handler :D