Jump to content

Search the Community

Showing results for tags 'Array variable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. Hello, I am getting this error message when running my script: Case $aButiD[0] To $aButiD[$iTotButtons - 1] Case ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. The script's purpose is to read my ini file and create buttons for the sections and section contents. The first part of the script creates buttons for the sections of the ini, once you click on the section button it should open another set of buttons of all the contents under the section In this case, the section in the .ini file is called "TPA" on the Func flavorco() It opens the contents of "TPA" into buttons. Right now, the section it is reading is determined by $sSection. It is only when I try to change $sSection = "TPA" to $sSection = $flavorco that the error starts to appear Here is the script #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> $optbar = IniReadSectionNames("test.ini") If Not IsArray($optbar) Then Exit Local $Button[UBound($optbar) - 1] $mGUI = GUICreate('Restock Flavor Ingredients', 10 + (130 * UBound($optbar)), 100) For $x = 1 To UBound($optbar) - 1 $var = IniReadSection("test.ini", $optbar[$x]) If @error Then ContinueLoop $X_Coord = 10 + (($x - 1) * 100) $Button[$x - 1] = GUICtrlCreateButton($optbar[$x], $X_Coord, 30, 70, 30) Next GUISetState() While 1 $mMsg = GUIGetMsg() If $mMsg = $GUI_EVENT_CLOSE Then GUIDelete($mGUI) ExitLoop EndIf For $i = 0 To UBound($Button) - 1 If $mMsg = $Button[$i] Then MsgBox(0, '$Msg = ' & $mMsg, GuiCtrlRead($Button[$i]) & ' Pressed', 2) Global $flavorco = $Button ; sets the flavor company's variable Call('flavorco') EndIf Next WEnd Func flavorco() ;opened flavor company's flavors MsgBox(0, '$Msg = ' & $mMsg, GuiCtrlRead($Button[$i]) & $flavorco, 0) Local $sFilePath = @ScriptDir & "\Test.ini" Local $sSection = $Button Local $aArray = IniReadSection($sFilePath, $sSection) _ArrayDelete($aArray, 0) ;_ArrayDisplay($aArray) Local $iIndex Local $iTotButtons = UBound($aArray) Local $iNumPerRow = 5 Local $iButWidth = 100 Local $iButDepth = 30 Local $aButiD[$iTotButtons] Local $hGUI = GUICreate('Ingredients Stock "' & $sFilePath & '"', 10 + ($iButWidth + 10) * $iNumPerRow, _ 10 + Ceiling($iTotButtons / $iNumPerRow) * ($iButDepth + 10), -1, $WS_EX_TOPMOST) For $i = 0 To $iTotButtons - 1 ; $x = $iXBorder + (($iRectWidth + $iSpacing) * Mod($i, $iNumCols)) $x = 10 + (($iButWidth + 10) * Mod($i, $iNumPerRow)) ; $y = $iYBorder + (($iRectDepth + $iSpacing) * Int($i / $iNumCols)) $y = 10 + (($iButDepth + 10) * Int($i / $iNumPerRow)) $aButiD[$i] = GUICtrlCreateButton($aArray[$i][0], $x, $y, $iButWidth, $iButDepth) ;, $BS_NOTIFY) Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) ExitLoop Case $aButiD[0] To $aButiD[$iTotButtons - 1] ;clicking on a flavor name $iIndex = ($msg - $aButiD[0]) $RSINGRflavor = $aArray[$iIndex][0] ;flavor name $RSINGRml = $aArray[$iIndex][1] ; ml $RSINGRgal = $aArray[$iIndex][1]*0.000264172 ;converts ml to gal Call('openflavor') EndSwitch WEnd EndFunc Func openflavor() #Region ### START Koda GUI section ### Form=F:\Karl\AutoIt\FJ-Stock JP\GUI Forms\RSINGRSUBFORM.kxf ;opens flavor to view stock and restock submit $RSINGRSUBFORM = GUICreate($sSection & " " & $RSINGRflavor, 242, 213, 530, 269) $RSINGRFlavorTitle = GUICtrlCreateLabel($sSection & " " & $RSINGRflavor, 32, 8, 200, 28) GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif") $RSINGRstockcaption = GUICtrlCreateLabel("Current Stock in ml:", 16, 48, 96, 17) $RSINGRstockml = GUICtrlCreateLabel($RSINGRml, 120, 48, 114, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $RSINGRInput = GUICtrlCreateInput("ml", 40, 112, 153, 21) $RSINGRSUBMIT = GUICtrlCreateButton("SUBMIT", 16, 152, 81, 33) $RSINGRCLOSE = GUICtrlCreateButton("CLOSE", 145, 151, 81, 33) $RSINGRgalcaption = GUICtrlCreateLabel("Current Stock in gal:", 16, 80, 97, 17) $RSINGRstockgal = GUICtrlCreateLabel($RSINGRGAL, 120, 80, 114, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; $msg = "" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($RSINGRSUBFORM) ExitLoop Case $RSINGRCLOSE GUIDelete($RSINGRSUBFORM) ExitLoop EndSwitch WEnd EndFunc Any help is much appreciated! Thanks. My guess is that $Button isn't an actual string?? Whenever I use msgbox it shows up the string exactly, no numbers attached. So i'm not sure whats going on here.
  2. I'm having a little difficulty getting beyond this error with the script below: C:\.....\Include\GuiListView.au3 (543) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) DllStructSetData($tBuffer, "Text", ^ ERROR Can someone point me in the right direction? Sample Lua script in spoiler. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> #include <GuiListView.au3> ;Opt('GuiOnEventMode', 1) ; prevents application from exiting ?? $Form1_1 = GUICreate("Script Parser", 1001, 801, -1, -1) $Button1 = GUICtrlCreateButton("Open File", 16, 24, 91, 25) $Button2 = GUICtrlCreateButton("Parse File", 125, 24, 91, 25) $Button3 = GUICtrlCreateButton("{undefined}", 234, 24, 91, 25) $Button4 = GUICtrlCreateButton("{undefined}", 343, 24, 91, 25) $Button5 = GUICtrlCreateButton("{undefined}", 452, 24, 91, 25) $Button6 = GUICtrlCreateButton("{undefined}", 561, 24, 91, 25) $Button7 = GUICtrlCreateButton("{undefined}", 670, 24, 91, 25) $Button8 = GUICtrlCreateButton("Save Output", 779, 24, 91, 25) $Button9 = GUICtrlCreateButton("Exit", 888, 24, 91, 25) $List1 = GUICtrlCreateList("", 8, 128, 177, 564, -1, $WS_EX_STATICEDGE) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 400, 0, "Courier New") $Edit1 = GUICtrlCreateEdit("", 200, 128, 793, 633, -1, $WS_EX_STATICEDGE) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 400, 0, "Courier New") $Label1 = GUICtrlCreateLabel("{empty}", 10, 700, 200, 27) GUICtrlSetFont(-1, 14, 400, 0, "Calibri") GUISetState(@SW_SHOW) GetFunctions() ; Assign to button 2 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OpenFile() EndFunc Func GetFunctions() Local $aFileName = FileOpenDialog("Select a file", @ScriptDir & "\", "(*.lua)", 0) Local $aArray = FileRead($aFileName) Local $aFunctions = _StringBetween($aArray, "Function ", "(") _ArrayDisplay($aFunctions) _GUICtrlListView_AddArray($List1,$aFunctions) ; ERROR EndFunc Func _ListViewEvent() For $i = 0 To $List1[0] If @GUI_CtrlId = $List1[$i] Then ExitLoop Next GUICtrlSetData($Label1, GUICtrlRead($List1[$i])) EndFunc Func _Exit() Exit EndFunc
  3. I have a question. I'm piecing together a small script that will read a computer's name and break it apart to determine computers exact location within a school district. This will help us with deploying software that needs to be specifically tweaked on a wide-scale without manually doing it per each classroom. With that in mind and knowing very little on storing data into arrays, I've decided to take on this challenge. The naming convention works like this: ###-#####-#### <12 is Max # of characters in name as well. Campus Abbreviation - Room Location - System Type - Count So, if I were at Rodney King Highschool in room 402 at a teachers computer, it would read: RHS-00402-DT01 (DT = Desktop Teacher) 01= number of system, if there were 2 teachers, there might be DT02 in the room as well. Anyways, with this naming convention in mind, this is the script broken down: #include <Array.au3> #include <CampusVariables.au3> Global $Computer = "MHS-0B234-DT22" Global $CampusLocation = _IsArrayItemInString ( $CAMPUS, $Computer ) Global $TrimABVR = StringLen($CAMPUS[$CampusLocation]) Global $RoomLocation = _IsArrayItemInString ( $CAMPUS_SELECTOR[$CampusLocation], StringTrimLeft($Computer, $TrimABVR + 1)) Global $SystemTypeCheck = _IsArrayItemInString ($SystemType, StringRight($Computer, 4)) ConsoleWrite ( "Campus Array : " & $CAMPUS[$CampusLocation] & @CRLF) ConsoleWrite ( "Room Array : " & $CAMPUS_SELECTOR[$CampusLocation[$RoomLocation]] & @CRLF) ConsoleWrite ( "System Type : " & $SystemType[$SystemTypeCheck] & @CRLF) Func _IsArrayItemInString ( $_Array, $_Item ) For $_A = 1 To UBound ( $_Array ) - 1 If $_Array[$_A] <> '' And StringInStr ( $_Item, $_Array[$_A], 2, 1, 1, StringLen($_Array[$_A])) <> 0 Then Return $_A ;Return ($_A & " and the value for this item is: " & $CAMPUS[$_A]) Next Return "This system is either not named properly or is not a system needing LanSchool configured. LanSchool will not be installed." EndFunc ;==> _IsArrayItemInString ( ) CampusVariables.au3 ;Workstation Type Variables Dim $SystemType[6] = ["DT","DA","DL","DS","MS"] Dim $AHS[21] = ["0A107","0A108","0A202","0B206","CM129","CM157","CM158","CM171","CM229","000F1","FA107","FA108","FA112","FA116","FA117","FA118","0V100","0V200","0V204","0V205","0V207"] Dim $MHS[25] = ["0A120","0A160","0A161","0A170","0A228","0A229","0A232","0A236","0A242","0A244","0B101","0B134","0B205","0B210","0B217","0B234","0C133","0C138","0C243","0C244","0C248","0D106","0D113","0D122","D158B"] Dim $ALC[4] = ["00118","00142","00218","00220"] Dim $AJH[2] = ["00209","00400"] Dim $FJH[2] = ["0A208","0B125"] Dim $HJH[3] = ["00116","00211","00223"] Dim $MJH[2] = ["00308","00406"] Dim $RJH[2] = ["0A124","0B125"] Dim $AES[2] = ["00403","00404"] Dim $APS[1] = ["00210"] Dim $DJE[3] = ["00119","00502","00703"] Dim $ECM[2] = ["0210A","0210B"] Dim $GYE[1] = ["00303"] Dim $HCE[2] = ["00300","00301"] Dim $LFE[2] = ["00418","00528"] Dim $LIW[2] = ["00106","00302"] Dim $MME[2] = ["00119","00501"] Dim $MTP[2] = ["00015","00016"] Dim $PME[2] = ["00501","00502"] Dim $RLS[2] = ["00108","00401"] Dim $SLE[2] = ["00106","00302"] Dim $WDE[2] = ["00CL1","00MR3"] Dim $TSD[2] = ["0LABA","0LABB"] ;Campus Name Variables Dim $CAMPUS[23] = ["AES","APS","DJE","ECM","GYE","HCE","LFE","MME","MTP","PME","RLS","SLE","WDE","LIW","AJH","FJH","HJH","MJH","RJH","AHS","MHS","ALC","TSD"] ;Campus Variables using the same array range as $CAMPUS. Dim $CAMPUS_SELECTOR[23] = [$AES,$APS,$DJE,$ECM,$GYE,$HCE,$LFE,$MME,$MTP,$PME,$RLS,$SLE,$WDE,$LIW,$AJH,$FJH,$HJH,$MJH,$RJH,$AHS,$MHS,$ALC,$TSD] Everything works except for one thing - I am trying to call the appropriate campus variable by what is returned for $CAMPUS when reading the name. Whenever $CAMPUS returns a number, I then call $CAMPUS_SELECTOR[$CampusLocation[$RoomLocation]] in an effort to call the appropriate variable and the corrosponding array number. Apparently I don't fully understand how this links together because it errors out: DevelopmentSrv1DevelopmentSoftwareLanSchool DeploymentInstall LanSchool.au3 (14) : ==> Campus Array : MHS Subscript used with non-Array variable.: ConsoleWrite ( "Room Array : " & $CAMPUS_SELECTOR[$CampusLocation[$RoomLocation]] & @CRLF) ConsoleWrite ( "Room Array : " & $CAMPUS_SELECTOR[$CampusLocation^ ERROR >Exit code: 1 Time: 0.214 Does anyone have insight on a better way to do this or perhaps point out material that would help me? I don't expect anyone to re-write my code, just give me a hint. I am trying hard to learn but I'm hitting my head.
×
×
  • Create New...