BrianCollier Posted May 14, 2007 Posted May 14, 2007 I'm trying to create a GUI window with several combo boxes arranged in a grid (similar to a suduko puzzle) I want to use an array to generate these combo boxes but I get an error of "Array variable subscript badly formatted" when I try to run it. Any suggestions? Thank you, Brian Collier #include <GuiConstants.au3> #include <array.au3> Dim $array[9][9] Dim $combo[9][9] Dim $x Dim $X Dim $y Dim $Y If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("SS", 190, 190, -1, -1 , $WS_OVERLAPPED + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Initial_Group_H_Offset = 5 $Initial_Group_V_Offset = 5 $Group_H_Offset = 100 $Group_V_Offset = 100 $Item_H_Offset = 30 $Item_V_Offset = 10 For $x = 1 to 9 For $y = 1 to 9 If $x = 3 OR $x = 6 OR $x = 9 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset * 2 ElseIf $x = 2 OR $x = 5 OR $x = 8 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset Else $H_Offset = $Initial_Group_H_Offset EndIf If $x = 1 OR $x = 2 OR $x = 3 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset * 2 ElseIf $x = 4 OR $x = 5 OR $x = 6 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset Else $V_Offset = $Initial_Group_V_Offset EndIf If $y = 3 OR $y = 6 OR $y = 9 Then $H_Offset = $H_Offset + $Item_H_Offset * 2 ElseIf $y = 2 OR $y = 5 OR $y = 8 Then $H_Offset = $H_Offset + $Item_H_Offset Else $H_Offset = $H_Offset EndIf If $y = 1 OR $y = 2 OR $y = 3 Then $V_Offset = $V_Offset + $Item_V_Offset * 2 ElseIf $y = 4 OR $y = 5 OR $y = 6 Then $V_Offset = $V_Offset + $Item_V_Offset Else $V_Offset = $V_Offset EndIf $X = $x - 1 $Y = $y - 1 $combo[$X][$Y] = GuiCtrlCreateCombo("", $H_Offset, $V_Offset, 30, 21) Next Next GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit
Xenobiologist Posted May 14, 2007 Posted May 14, 2007 Hi, here you 'll see you prob: expandcollapse popup#include<GUIConstants.au3> Dim $array[10][10] Dim $combo[19][19] Dim $x Dim $x Dim $y Dim $y ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GUICreate("SS", 190, 190, -1, -1, $WS_OVERLAPPED + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Initial_Group_H_Offset = 5 $Initial_Group_V_Offset = 5 $Group_H_Offset = 100 $Group_V_Offset = 100 $Item_H_Offset = 30 $Item_V_Offset = 10 For $x = 1 To 9 For $y = 1 To 9 If $x = 3 Or $x = 6 Or $x = 9 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset * 2 ElseIf $x = 2 Or $x = 5 Or $x = 8 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset Else $H_Offset = $Initial_Group_H_Offset EndIf If $x = 1 Or $x = 2 Or $x = 3 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset * 2 ElseIf $x = 4 Or $x = 5 Or $x = 6 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset Else $V_Offset = $Initial_Group_V_Offset EndIf If $y = 3 Or $y = 6 Or $y = 9 Then $H_Offset = $H_Offset + $Item_H_Offset * 2 ElseIf $y = 2 Or $y = 5 Or $y = 8 Then $H_Offset = $H_Offset + $Item_H_Offset Else $H_Offset = $H_Offset EndIf If $y = 1 Or $y = 2 Or $y = 3 Then $V_Offset = $V_Offset + $Item_V_Offset * 2 ElseIf $y = 4 Or $y = 5 Or $y = 6 Then $V_Offset = $V_Offset + $Item_V_Offset Else $V_Offset = $V_Offset EndIf $x = $x + 1 $y = $y + 1 ConsoleWrite('x : ' & $x & ' y : ' & $y & @CRLF) $combo[$x][$y] = GUICtrlCreateCombo("", $H_Offset, $V_Offset, 30, 21) Next Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Ragnar Posted November 10, 2009 Posted November 10, 2009 Hi, here you 'll see you prob: expandcollapse popup#include<GUIConstants.au3> Dim $array[10][10] Dim $combo[19][19] Dim $x Dim $x Dim $y Dim $y ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GUICreate("SS", 190, 190, -1, -1, $WS_OVERLAPPED + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Initial_Group_H_Offset = 5 $Initial_Group_V_Offset = 5 $Group_H_Offset = 100 $Group_V_Offset = 100 $Item_H_Offset = 30 $Item_V_Offset = 10 For $x = 1 To 9 For $y = 1 To 9 If $x = 3 Or $x = 6 Or $x = 9 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset * 2 ElseIf $x = 2 Or $x = 5 Or $x = 8 Then $H_Offset = $Initial_Group_H_Offset + $Group_H_Offset Else $H_Offset = $Initial_Group_H_Offset EndIf If $x = 1 Or $x = 2 Or $x = 3 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset * 2 ElseIf $x = 4 Or $x = 5 Or $x = 6 Then $V_Offset = $Initial_Group_V_Offset + $Group_V_Offset Else $V_Offset = $Initial_Group_V_Offset EndIf If $y = 3 Or $y = 6 Or $y = 9 Then $H_Offset = $H_Offset + $Item_H_Offset * 2 ElseIf $y = 2 Or $y = 5 Or $y = 8 Then $H_Offset = $H_Offset + $Item_H_Offset Else $H_Offset = $H_Offset EndIf If $y = 1 Or $y = 2 Or $y = 3 Then $V_Offset = $V_Offset + $Item_V_Offset * 2 ElseIf $y = 4 Or $y = 5 Or $y = 6 Then $V_Offset = $V_Offset + $Item_V_Offset Else $V_Offset = $V_Offset EndIf $x = $x + 1 $y = $y + 1 ConsoleWrite('x : ' & $x & ' y : ' & $y & @CRLF) $combo[$x][$y] = GUICtrlCreateCombo("", $H_Offset, $V_Offset, 30, 21) Next Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit So long, Mega
Ragnar Posted November 10, 2009 Posted November 10, 2009 Somewhere your variable becomes less than zero. You can't have a negative subscript -- thus the error.
GodlessSinner Posted November 11, 2009 Posted November 11, 2009 (edited) expandcollapse popup#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $combo[82],$Group[10], $cnt = 0, $gcnt = 0, $x = 16, $y = 24, $gx = 8, $gy= 10 $Form1 = GUICreate("Form1", 500, 350, 364, 398) ;Creating groups For $i = 1 To 3 Step 1 For $j = 1 To 3 Step 1 $gcnt +=1 $Group[$gcnt] = GUICtrlCreateGroup("", $gx, $gy, 153, 110) $gx +=153 Next $gx = 8 $gy+=105 Next ;creating combos For $i = 1 To 9 Step 1 For $j = 1 To 9 Step 1 $cnt +=1 $Combo[$cnt] = GUICtrlCreateCombo("", $x, $y, 41, 25) $x +=50 Next $x = 16 $y+=35 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd - So easier.. Edited November 11, 2009 by Godless _____________________________________________________________________________
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