Wingens Posted January 2, 2017 Share Posted January 2, 2017 Hi, I am trying to create a list view wich shows the content of an ini file. There is a pulldown menu wich allows me to check a certain status in the ini file if the status is found it should read out the key and in every section the same key is located after that it should fill out the listview with all results found. expandcollapse popup$OVERZICHTGUI = GUICreate("RMA Overzicht", 1235, 742, -1, -1) GUICtrlCreateLabel("Ingelogd als: " & $NAAMMEDEWERKER, 8, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", 8, 16, 185, 89) GUICtrlCreateLabel("Status:", 32, 40, 37, 17) $STATUS = GUICtrlCreateCombo("", 32, 64, 140, 25,BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($STATUS, "Aangevraagd|Verzonden|Afgehandeld", "") GUICtrlCreateGroup("", -99, -99, 1, 1) $View = GUICtrlCreateListView("RMANR|RMANRLEV|DEBITNR|KLANT|STATUS|MODEL|SERIENR|AANGEMELDDOOR|AANMELDDATUM|VERZENDDATUM|RETOURDATUM|KLACHT|OPLOSSING", 8, 120, 1218, 614) $Exit = GUICtrlCreateButton("Hoofdmenu", 1104, 8, 123, 33) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $EXIT $YesOrNo = msgBox(4,"","Terug naar het hoofdmenu?") If $YesOrNo = 6 then GUIDelete($OVERZICHTGUI) MAINMENU() ExitLoop EndIf Case $STATUS $GO = 1 $STATE = GUICtrlRead($STATUS) Local $aArray = IniReadSection(@ScriptDir & "\DB\rma.ini", "STATUS") _ArrayDisplay($aArray, "Gevonden") $FOUNDRMANR = _ArraySearch($aArray, $STATE) MsgBox(4096, "", $FOUNDRMANR) If $FOUNDRMANR = -1 Then MsgBox(4096, "Not Found", "No RMA requests with this status found.") $GO = 0 EndIf If $GO = 1 Then $VAR = IniRead(@ScriptDir & "\DB\rma.ini", "RMANR", $FOUNDRMANR, "Not found") MsgBox(4096, "", $VAR) EndIf EndSwitch WEnd rma-forum.ini Link to comment Share on other sites More sharing options...
ur Posted January 2, 2017 Share Posted January 2, 2017 (edited) I am trying to run your script but getting error as below. Please share te MAINMENU() also. Edited January 2, 2017 by ur Link to comment Share on other sites More sharing options...
Subz Posted January 2, 2017 Share Posted January 2, 2017 Had the same issue as UR, however here is how I would do it: expandcollapse popup#include <Array.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> FNC_RMAGUI() Func FNC_RMAGUI() Local $hINI_FILENAME = @ScriptDir & "\DB\rma.ini" Local $aINI_SECTIONS[13] = ['RMANR', 'RMANRLEV', 'DEBITNR', 'KLANT', 'STATUS', 'MODEL', 'SERIENR', 'AANGEMELDDOOR', 'AANMELDDATUM', 'VERZENDDATUM', 'RETOURDATUM', 'KLACHT', 'OPLOSSING'] ;~ Sections that should be read from Ini and added to ListView, also used as ListView Header Local $aOptions = IniReadSection($hINI_FILENAME, 'Options') ;~ Use the Options section to populate the ComboBox Local $NAAMMEDEWERKER = 'NAAMEDWERKER' ;~ Remove this $OVERZICHTGUI = GUICreate("RMA Overzicht", 1235, 742, -1, -1) GUICtrlCreateLabel("Ingelogd als: " & $NAAMMEDEWERKER, 8, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", 8, 16, 185, 89) GUICtrlCreateLabel("Status:", 32, 40, 37, 17) $STATUS = GUICtrlCreateCombo("", 32, 64, 140, 25,BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($STATUS, _ArrayToString($aOptions, '|', 1, -1, '|', 0, 0), "") GUICtrlCreateGroup("", -99, -99, 1, 1) $hGUI_LISTVIEW = GUICtrlCreateListView(_ArrayToString($aINI_SECTIONS), 8, 120, 1218, 614) $Exit = GUICtrlCreateButton("Hoofdmenu", 1104, 8, 123, 33) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EXIT $YesOrNo = msgBox(4,"","Terug naar het hoofdmenu?") If $YesOrNo = 6 then GUIDelete($OVERZICHTGUI) ; MAINMENU() ;~ Commented for test purposes ExitLoop EndIf Case $STATUS $STATE = GUICtrlRead($STATUS) Local $sSTATUS = IniRead($hINI_FILENAME, 'Options', $STATE, 'Not Found') If $sSTATUS <> 'Not Found' Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW) ;~ Remove this if you just want to append the data to the ListView without removing all items $sListViewItem = '' For $x = 0 To UBound($aINI_SECTIONS) - 1 If $x = UBound($aINI_SECTIONS) - 1 Then $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$x], $sSTATUS, -1) ExitLoop EndIf $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$x], $sSTATUS, -1) & '|' Next GUICtrlCreateListViewItem($sListViewItem, $hGUI_LISTVIEW) EndIf EndSwitch WEnd EndFunc In your Ini file add the following: [Options] Afgehandeld=1 Verzonden=3 Aangevraagd=4 Link to comment Share on other sites More sharing options...
Wingens Posted January 2, 2017 Author Share Posted January 2, 2017 (edited) @Subz The script is working only problem is, when there are multiple entries in the ini file using the same status it only shows 1 result in the listview. Any idea's on this? Edited January 2, 2017 by Wingens Link to comment Share on other sites More sharing options...
Subz Posted January 2, 2017 Share Posted January 2, 2017 Can you re-post the ini file with multiple entries, I'm not really sure what you mean by "when there are multiple entries in the ini file using the same status it only shows 1 result in the listview." Currently how the script works is when you select an option for example: "Verzonden" in the ComboBox it gets the status id from [Options] - Verzonden so the result is "3", it then reads each section referenced in $aINI_SECTIONS with the Ini Key "3". Ini Keys should be unique in each section, as IniRead will only pick up 1 key. You could add multiple keys and use IniReadSection but I wouldn't recommend it as it will cause more problems especially if the keys are not written in the correct order. Can you confirm that is what you're referring to or is it something else? Link to comment Share on other sites More sharing options...
Wingens Posted January 2, 2017 Author Share Posted January 2, 2017 Every RMA request gets an unique ID Example: [STATUS] 1=Afgehandeld 3=Aangevraagd 4=Aangevraagd 5=Aangevraagd ID 3,4 and 5 have the same status, when i choose the status: Aangevraagd it show in the listview only ID: 4 instead of 3,4 and 5. Hope this helps. v0.2.au3 rma.ini medewerker.ini Link to comment Share on other sites More sharing options...
Subz Posted January 2, 2017 Share Posted January 2, 2017 Think I understand now, can you try this: NB: You can remove Options Section from the Ini as its no longer required. expandcollapse popupFunc OVERZICHT() Local $hINI_FILENAME = @ScriptDir & "\DB\rma.ini" Local $aINI_SECTIONS[13] = ['RMANR', 'RMANRLEV', 'DEBITNR', 'KLANT', 'STATUS', 'MODEL', 'SERIENR', 'AANGEMELDDOOR', 'AANMELDDATUM', 'VERZENDDATUM', 'RETOURDATUM', 'KLACHT', 'OPLOSSING'] ;~ Sections that should be read from Ini and added to ListView, also used as ListView Header Local $aSTATUS_SECTION = IniReadSection($hINI_FILENAME, 'STATUS') ;~ Use the Options section to populate the ComboBox Local $aSTATUS_ITEMS[0] $OVERZICHTGUI = GUICreate("RMA Overzicht", 1235, 742, -1, -1) GUICtrlCreateLabel("Ingelogd als: " & $NAAMMEDEWERKER, 8, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", 8, 16, 185, 89) GUICtrlCreateLabel("Status:", 32, 40, 37, 17) $STATUS = GUICtrlCreateCombo("", 32, 64, 140, 25,BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($STATUS, _ArrayToString(_ArrayUnique($aSTATUS_SECTION, 1), '|', 1, -1, '|', 1, 1), "") GUICtrlCreateGroup("", -99, -99, 1, 1) $hGUI_LISTVIEW = GUICtrlCreateListView(_ArrayToString($aINI_SECTIONS), 8, 120, 1218, 614) $Exit = GUICtrlCreateButton("Hoofdmenu", 1104, 8, 123, 33) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EXIT $YesOrNo = msgBox(4,"","Terug naar het hoofdmenu?") If $YesOrNo = 6 then GUIDelete($OVERZICHTGUI) MAINMENU() ExitLoop EndIf Case $STATUS $STATE = GUICtrlRead($STATUS) $aSTATUS_INDEX = _ArrayFindAll($aSTATUS_SECTION, $STATE, 1, 0, 0, 0, 1) ReDim $aSTATUS_ITEMS[UBound($aSTATUS_INDEX)] For $i = 0 To UBound($aSTATUS_INDEX) - 1 $aSTATUS_ITEMS[$i] = $aSTATUS_SECTION[$aSTATUS_INDEX[$i]][0] Next If IsArray($aSTATUS_ITEMS) Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW) ;~ Remove this if you just want to append the data to the ListView without removing all items For $i = 0 To UBound($aSTATUS_ITEMS) - 1 $sListViewItem = '' For $j = 0 To UBound($aINI_SECTIONS) - 1 If $j = UBound($aINI_SECTIONS) - 1 Then $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$j], $aSTATUS_ITEMS[$i], -1) ExitLoop EndIf $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$j], $aSTATUS_ITEMS[$i], -1) & '|' Next GUICtrlCreateListViewItem($sListViewItem, $hGUI_LISTVIEW) Next EndIf EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
Wingens Posted January 3, 2017 Author Share Posted January 3, 2017 The scripts crashed with this in the console: "C:\Program Files (x86)\AutoIt3\Include\Array.au3" (2297) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If IsInt($aArray[$iBase]) Then If IsInt(^ ERROR Link to comment Share on other sites More sharing options...
Subz Posted January 3, 2017 Share Posted January 3, 2017 Using the script + ini from Post#7 changing only the OVERZICHT function, I can't get it to crash, have you updated the Ini or the script? Link to comment Share on other sites More sharing options...
Wingens Posted January 3, 2017 Author Share Posted January 3, 2017 i have updated both rma.ini v0.2.au3 Link to comment Share on other sites More sharing options...
Subz Posted January 3, 2017 Share Posted January 3, 2017 Sorry still can't get it to crash, however looking at Array.au3 line 2297 indicates it's related to _ArrayUnique not sure if the issue is because it's used within _ArrayToString so split it up, can you try: expandcollapse popupFunc OVERZICHT() Local $hINI_FILENAME = @ScriptDir & "\DB\rma.ini" Local $aINI_SECTIONS[13] = ['RMANR', 'RMANRLEV', 'DEBITNR', 'KLANT', 'STATUS', 'MODEL', 'SERIENR', 'AANGEMELDDOOR', 'AANMELDDATUM', 'VERZENDDATUM', 'RETOURDATUM', 'KLACHT', 'OPLOSSING'] ;~ Sections that should be read from Ini and added to ListView, also used as ListView Header Local $aSTATUS_SECTION = IniReadSection($hINI_FILENAME, 'STATUS') ;~ Use the Options section to populate the ComboBox Local $sSTATUS_SECTION = _ArrayUnique($aSTATUS_SECTION, 1) $sSTATUS_SECTION = _ArrayToString($sSTATUS_SECTION, '|', 1, -1, '|', 1, 1) Local $aSTATUS_ITEMS[0] $OVERZICHTGUI = GUICreate("RMA Overzicht", 1235, 742, -1, -1) GUICtrlCreateLabel("Ingelogd als: " & $NAAMMEDEWERKER, 8, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", 8, 16, 185, 89) GUICtrlCreateLabel("Status:", 32, 40, 37, 17) $STATUS = GUICtrlCreateCombo("", 32, 64, 140, 25,BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($STATUS, $sSTATUS_SECTION, "") GUICtrlCreateGroup("", -99, -99, 1, 1) $hGUI_LISTVIEW = GUICtrlCreateListView(_ArrayToString($aINI_SECTIONS), 8, 120, 1218, 614) $Exit = GUICtrlCreateButton("Hoofdmenu", 1104, 8, 123, 33) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EXIT $YesOrNo = msgBox(4,"","Terug naar het hoofdmenu?") If $YesOrNo = 6 then GUIDelete($OVERZICHTGUI) MAINMENU() ExitLoop EndIf Case $STATUS $STATE = GUICtrlRead($STATUS) $aSTATUS_INDEX = _ArrayFindAll($aSTATUS_SECTION, $STATE, 1, 0, 0, 0, 1) ReDim $aSTATUS_ITEMS[UBound($aSTATUS_INDEX)] For $i = 0 To UBound($aSTATUS_INDEX) - 1 $aSTATUS_ITEMS[$i] = $aSTATUS_SECTION[$aSTATUS_INDEX[$i]][0] Next If IsArray($aSTATUS_ITEMS) Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW) ;~ Remove this if you just want to append the data to the ListView without removing all items For $i = 0 To UBound($aSTATUS_ITEMS) - 1 $sListViewItem = '' For $j = 0 To UBound($aINI_SECTIONS) - 1 If $j = UBound($aINI_SECTIONS) - 1 Then $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$j], $aSTATUS_ITEMS[$i], -1) ExitLoop EndIf $sListViewItem &= IniRead($hINI_FILENAME, $aINI_SECTIONS[$j], $aSTATUS_ITEMS[$i], -1) & '|' Next GUICtrlCreateListViewItem($sListViewItem, $hGUI_LISTVIEW) Next EndIf EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
Wingens Posted January 3, 2017 Author Share Posted January 3, 2017 Still get the same error... i also included the au3 file v0.2.au3 rma.ini Array.au3 Link to comment Share on other sites More sharing options...
Subz Posted January 3, 2017 Share Posted January 3, 2017 Can you update AutoIT it appears you're using an old version. A fix was applied in 3.3.14.2 https://www.autoitscript.com/trac/autoit/ticket/3078 to fix the issue you're experiencing. Link to comment Share on other sites More sharing options...
Wingens Posted January 3, 2017 Author Share Posted January 3, 2017 Ah damn that was it! thank you so much. Link to comment Share on other sites More sharing options...
KickStarter15 Posted January 3, 2017 Share Posted January 3, 2017 @Wingens, Hope you've tried using an Array with _FileReadToArray() and then loop it though the ini file to add them as line at the time with GUICtrlCreateListViewItem(). You can use $GUI_HIDE and $GUI_SHOW to filter GUICtrlCreateListViewItem() GUICtrlSetState($listview1, $GUI_HIDE) - ;to hide ID's GUICtrlSetState($listview2, $GUI_SHOW) - ;to show desired ID Just trying if it make sense. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
KickStarter15 Posted January 3, 2017 Share Posted January 3, 2017 I wasn't able to check on your response. Good, hope it worked perfectly. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. 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