Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
i think one of the problems is that in you checkwin, your exceeding the array bounds of $checkme[8]. the other thing is you might want to pass the index number of the button in your choose_click() as a straight number, ie:$one=$Board.addcmdbutton("cmdStyle1",$1,1,1,98,98,"Choose_click($$one,0,$$input)") anyways, i made a couple of small changes, hope you don't mind: code:
Break on ;SetConsole("hide") $input = "X" global $Checkme[8] $Checkme[0] = "N" $Checkme[1] = "N" $Checkme[2] = "N" $Checkme[3] = "N" $Checkme[4] = "N" $Checkme[5] = "N" $Checkme[6] = "N" $Checkme[7] = "N" $Checkme[8] = "N" $root=createobject("Kixgui.Desktop") If Len($root)=0 Exit 1 EndIf ; Draws the Starting Board and places it on the Screen $Board = $root.createform("FrmBoard","Tic Tac Toe Board") $Board.Width = 310 $Board.Height = 340 $Board.Top = ($Board.parent.height - $Board.height) / 2 $Board.Left = ($root.width - $Board.width ) / 2 ; Draws the lines to seperate the board. ;$PegPos = $Board.addlabel("Lblstyle1","",0,0,100,100) ;$PegPos.borderstyle = 1 ;$Pegpos.textalign=1 ;center $one=$Board.addcmdbutton("cmdStyle1",$1,1,1,98,98,"Choose_click($$one,0,$$input)") $one.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle2","",0,100,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Two=$Board.addcmdbutton("cmdStyle2",$2,1,99,98,100,"Choose_click($$two,1,$$input)") $Two.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle3","",0,200,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Three =$Board.addcmdbutton("cmdStyle3",$3,0,199,99,99,"Choose_click($$Three,2,$$input)") $Three.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle4","",100,0,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Four =$Board.addcmdbutton("cmdStyle4",$4,99,1,100,98,"Choose_click($$four,3,$$input)") $Four.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle5","",100,100,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Five =$Board.addcmdbutton("cmdStyle5",$5,99,99,100,100,"Choose_click($$five,4,$$input)") $Five.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle6","",100,200,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Six =$Board.addcmdbutton("cmdStyle6",$6,99,199,100,99,"Choose_click($$six,5,$$input)") $Six.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle7","",200,0,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Seven =$Board.addcmdbutton("cmdStyle7",$7,199,1,98,98,"Choose_click($$seven,6,$$input)") $Seven.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle8","",200,100,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Eight=$Board.addcmdbutton("cmdStyle8",$8,199,99,99,100,"Choose_click($$eight,7,$$input)") $Eight.borderstyle=1 $PegPos = $Board.addlabel("Lblstyle9","",200,200,100,100) $PegPos.borderstyle = 1 $Pegpos.textalign=1 ;center $Nine =$Board.addcmdbutton("cmdStyle9",$9,199,199,99,99,"Choose_click($$nine,8,$$input)") $Nine.borderstyle=1 ; Makes the board Visible$Board.visible = 1 While ($Board.visible) OR ($playagain = "no") $=Execute($Board.lastevent()) Loop Exit Function Choose_click($Pick,$num,$Check) If ($Pick.Caption = "X") OR ($Pick.Caption ="O") $RC = MessageBox("Try an Empty Square","Box in use",1,3) Exit Else $Pick.caption = $input $Checkme[$num] = $check $Win = CheckWin($Check) if $win = "YES" $=messagebox("$check won!","",0) endif If $Check = "X" $input = "O" Else $Input = "X" EndIf EndIf Exit EndFunction Function Checkwin($input) Select Case ($checkme[0] = $input) AND ($Checkme[1] = $input) AND ($checkme[2] = $input) $checkwin = "YES" Case ($checkme[3] = $input) AND ($Checkme[4] = $input) AND ($checkme[5] = $input) $checkwin = "YES" Case ($checkme[6] = $input) AND ($Checkme[7] = $input) AND ($checkme[8] = $input) $checkwin = "YES" Case ($checkme[0] = $input) AND ($Checkme[3] = $input) AND ($checkme[6] = $input) $checkwin = "YES" Case ($checkme[1] = $input) AND ($Checkme[4] = $input) AND ($checkme[7] = $input) $checkwin = "YES" Case ($checkme[2] = $input) AND ($Checkme[5] = $input) AND ($checkme[8] = $input) $checkwin = "YES" Case ($checkme[0] = $input) AND ($Checkme[4] = $input) AND ($checkme[8] = $input) $checkwin = "YES" Case ($checkme[2] = $input) AND ($Checkme[4] = $input) AND ($checkme[6] = $input) $checkwin = "YES" Case 1 $Checkwin = "NO" EndSelect EndFunction
-Shawn
|