Ahmad Posted September 19, 2008 Share Posted September 19, 2008 Hi all, i was trying to make a function called _GuiCtrlgrid_Create but it doesn't work -.- when i execute the include file it dowsn' show any errors but when i call the function it gives me an eror : C:\Documents and Settings\Administrator\My Documents\Grid.au3 (23) : ==> Array variable subscript badly formatted.: Dim $Square[($iHorizontalSquares + 1)][($iVerticalSquares + 1)] Dim $Square[($iHorizontalSquares + 1)][^ ERRORHere is the Include file : #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include-once Func _GUICtrlGrid_Create($iXCoord, $iYCoord, $iWidth, $iHeight = -1, $iHorizontalSquares = -1, $iVerticalSquares = -1, $hSquaresColor = 0xFFFFFF, $bGridShow = True) Local $Square Select Case $iHorizontalSquares = -1 $iHorizontalSquares = $iWidth / 12 Case $iVerticalSquares = -1 $iVerticalSquares = $iHeight / 12 Case $iHeight = -1 $iHeight = $iWidth Case $bGridShow = False $bGridShow = -1 Case $bGridShow = True $bGridShow = $WS_BORDER EndSelect Dim $Square[($iHorizontalSquares + 1)][($iVerticalSquares + 1)] For $HorizontalLine = 1 To $iHorizontalSquares For $VerticalLine = 1 To $iVerticalSquares $Square[$HorizontalLine][$VerticalLine] = GUICtrlCreateLabel("", $iXCoord * $HorizontalLine, $iYCoord * $VerticalLine, $iWidth, $iHeight, $bGridShow) GUICtrlSetBkColor(-1, $hSquaresColor) Next Next Return $Square EndFunc ;==>_GUICtrlGrid_Create and the script i try to run is : #include "Grid.au3" #include "GuiConstantsEx.au3" #include "WindowsConstants.au3" $gui = GuiCreate("Grid Example") $x = _GuiCtrlGrid_Create(5,5,100) GUISetState(@SW_SHOW) while 1 WEnd Thanks in Advance [center]I want to change the world ...., but I don't have the source code xD[/center] Link to comment Share on other sites More sharing options...
Azazash Posted September 19, 2008 Share Posted September 19, 2008 (edited) Try this expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include-once Func _GUICtrlGrid_Create($iXCoord, $iYCoord, $iWidth, $iHeight = -1, $iHorizontalSquares = -1, $iVerticalSquares = -1, $hSquaresColor = 0xFFFFFF, $bGridShow = True) Local $Square If $iHorizontalSquares = -1 Then $iHorizontalSquares = $iWidth / 12 EndIf If $iHeight = -1 Then $iHeight = $iWidth EndIf If $iVerticalSquares = -1 Then $iVerticalSquares = $iHeight / 12 endif If $bGridShow = False Then $bGridShow = -1 EndIf If $bGridShow = True Then $bGridShow = $WS_BORDER EndIf Dim $Square[($iHorizontalSquares +1)][($iVerticalSquares +1)] For $HorizontalLine = 1 To $iHorizontalSquares For $VerticalLine = 1 To $iVerticalSquares $Square[$HorizontalLine][$VerticalLine] = GUICtrlCreateLabel("", $iXCoord * $HorizontalLine, $iYCoord * $VerticalLine, $iWidth, $iHeight, $bGridShow) GUICtrlSetBkColor(-1, $hSquaresColor) Next Next Return $Square EndFunc ;==>_GUICtrlGrid_Create $gui = GuiCreate("Grid Example") $x = _GuiCtrlGrid_Create(5,5,100) GUISetState(@SW_SHOW) while 1 WEnd changed your selects to if and it seems to work. EDIT, oh and the reason for the array failure was because you didn't have a valid value for iVerticalSquares, because it wasn't goping through the selects Edited September 19, 2008 by Azazash Link to comment Share on other sites More sharing options...
Ahmad Posted September 19, 2008 Author Share Posted September 19, 2008 ah Thanks [center]I want to change the world ...., but I don't have the source code xD[/center] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now