Jump to content

Strange Problem getting .ini data to combo


telmob
 Share

Recommended Posts

I'm trying to put data from an ini file in a combo when a previous combo data is selected.

For example, in the following code when the user selects data from the first combo ($AnoEmissaoLaudo), the following combo ($Cliente1) will display data from the section name previously selected in the first combo.

And the third combo ($NumeroLaudoGrupoAbrir) should display data from the section selected in the previous combo ($Cliente1), but i get this annoying error in this last combo, don't know why. The previous combo works!

"Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

For $i = 1 To $ReadReportNumber[0]

For $i = 1 To ^ ERROR"

The second and third combos read data from the file 2011.ini that has the following info:

[Client1]

03-09 0064=

[Client2]

03-09 0065=

03-09 0066=

03-09 0067=

03-09 0068=

03-09 0069=

03-09 0070=

The code:

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $AnoEmissaoLaudo
$ReadClients = IniReadSectionNames(@ScriptDir & "\data\src\"&GUICtrlRead($AnoEmissaoLaudo)&"\"&GUICtrlRead($AnoEmissaoLaudo)&".ini")
For $i = 1 To $ReadClients[0]
GUICtrlSetData($Cliente1, $ReadClients[$i]) ; ==<
Next
Case $Cliente1
$ReadReportNumber = IniReadSection(@ScriptDir & "\data\src\"&GUICtrlRead($AnoEmissaoLaudo)&"\"&GUICtrlRead($AnoEmissaoLaudo)&".ini", GUICtrlRead($Cliente1))
For $i = 1 To $ReadReportNumber[0]
GUICtrlSetData($NumeroLaudoGrupoAbrir, $ReadReportNumber[$i]) ; ==<
Next
EndSwitch
WEnd
EndFunc
Edited by telmob
Link to comment
Share on other sites

I know the forum software was recently updowngraded, but you'll have to edit that post into a usable form.

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Here is a working example. The folder @ScriptDir & "\data\src\" contains only the ini file 2011.ini

#include <String.au3>

#include <ButtonConstants.au3>

#include <ComboConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <Array.au3>

#include <GUIConstants.au3>

#include <EditConstants.au3>

#Include <GuiComboBox.au3>

$FileList=_FileListToArray(@ScriptDir & "\data\src\")

$FolderList=_ArrayToString($FileList,"",1,"")

$Form1 = GUICreate("Form1", 192, 452, 753, 167)

$Group1 = GUICtrlCreateGroup("Visualizar/Editar Laudo", 12, 199, 169, 225)

$AnoEmissaoLaudo = GUICtrlCreateCombo("Ano de Emissão", 20, 230, 153, 25, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))

GUICtrlSetData(-1, $FolderList)

$Cliente1 = GUICtrlCreateCombo("Cliente", 20, 270, 153, 25, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))

$NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Data / Número de Laudo", 20, 310, 153, 25, BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL))

$AbrirLaudo = GUICtrlCreateButton("Abrir Laudo", 44, 350, 107, 25)

$EditarLaudo = GUICtrlCreateButton("Editar Laudo", 44, 382, 107, 25)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $AnoEmissaoLaudo

$ReadClients = IniReadSectionNames(@ScriptDir & "\data\src\2011\2011.ini")

For $i = 1 To $ReadClients[0]

GUICtrlSetData($Cliente1, $ReadClients[$i])

Next

Case $Cliente1

$ReadReportNumber = IniReadSection(@ScriptDir & "\data\src\2011\2011.ini", GUICtrlRead($Cliente1))

For $i = 1 To $ReadReportNumber[0]

GUICtrlSetData($NumeroLaudoGrupoAbrir, $ReadReportNumber[$i])

Next

EndSwitch

WEnd

EndFunc

Edited by telmob
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...