Jump to content

Recommended Posts

Posted
#include <GUIConstantsEx.au3>
AutoItSetOption( "MustDeclareVars", 0)
Global $idMsg, $button[8][8],$i,$j
Local $gui = GUICreate( "Board Game", 700, 700)
GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Exitt")
For $i = 0 To 7
   For $j = 0 To 7
$button[$i][$j] = GUICtrlCreateButton("", 448-56*$i,448-56*$j,56,56)
Next
Next
While 1
   $idMsg = GUIGetMsg()
   Select
   Case $idMsg = $button[$i][$j]
      GUICtrlSetState($msg,128)
   Case $idMsg = $GUI_EVENT_CLOSE
      Exit 0
   EndSelect
   Sleep(10)
WEnd

Hello, this is my first time posting in forum yet I was trying to make a game with autoit and this is my code.

How can I understand what button just hitted ? I saw checkers post by someone in forum but I couldnt understand it.

(15) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
Case $idMsg = $button[$i][$j]
Case $idMsg = ^ ERROR

  • Developers
Posted

Don't think so as you can see in a Tidied version:

#include <GUIConstantsEx.au3>
AutoItSetOption("MustDeclareVars", 0)
Global $idMsg, $button[8][8], $i, $j
Local $gui = GUICreate("Board Game", 700, 700)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitt")
For $i = 0 To 7
    For $j = 0 To 7
        $button[$i][$j] = GUICtrlCreateButton("", 448 - 56 * $i, 448 - 56 * $j, 56, 56)
    Next
Next
While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $button[$i][$j]
            GUICtrlSetState($msg, 128)
        Case $idMsg = $GUI_EVENT_CLOSE
            Exit 0
    EndSelect
    Sleep(10)
WEnd

So my guess is they are both set to 8.....

This posted script has other errors too.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...