Jump to content
Wingens

Read ini file and fill listview

Recommended Posts

Wingens

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.

 

$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

Share this post


Link to post
Share on other sites
ur

I am trying to run your script but getting error as below.

assa.PNG

Please share te MAINMENU() also.

 

Edited by ur

Share this post


Link to post
Share on other sites
Subz

Had the same issue as UR, however here is how I would do it:

#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

 

Share this post


Link to post
Share on other sites
Wingens

@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 by Wingens

Share this post


Link to post
Share on other sites
Subz

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?

 

Share this post


Link to post
Share on other sites
Wingens

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

Share this post


Link to post
Share on other sites
Subz

Think I understand now, can you try this:

NB: You can remove Options Section from the Ini as its no longer required.

Func 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

 

Share this post


Link to post
Share on other sites
Wingens

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

Share this post


Link to post
Share on other sites
Subz

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?

Share this post


Link to post
Share on other sites
Subz

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:

Func 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

 

Share this post


Link to post
Share on other sites
Wingens

Ah damn that was it! thank you so much.

Share this post


Link to post
Share on other sites
KickStarter15

@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.

Share this post


Link to post
Share on other sites
KickStarter15

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.

Share this post


Link to post
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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      hi dears
      am using an ini files as a History
      Sometimes the file size is be larger to 5 MB
      AutoIt does not recognize the full content of the file
      When I did a search to find out why, I discovered that INI files could not be read if they size larger than 64 KB.
      for that I preferred to ask here if is there any way to bypass this obstacle.
      The contents of the file are  as follows
      [filesList]
      c:\...\...\f1.mp3=00:15:20
      c:\...\...\f2.mp3=00:10:20
      c:\...\...\f3.wav=00:59:20
      ....... Etc
      This is the section for reading the file (adapted from my main script)

      case $continue     Local $aArray = IniReadSection($WaitingListFile, StringEncrypt(true, "filesList", $MyPassword))     If Not @error Then Opt("GUICloseOnESC", 1) _GUICtrlListView_DeleteAllItems($scList)         For $i = 1 To $aArray[0][0] $path = path_list(StringEncrypt(false, $aArray[$i][0], $MyPassWord), 1) if FileExists(StringEncrypt(false, $aArray[$i][0], $MyPassWord)) then GUICtrlCreateListViewItem(_GetFileName(FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord))) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord)), $scList) else $path = $path endIf         Next GUISetState(@sw_disable, $hGUI) GUISetState(@sw_show, $hGUI2) GUICtrlSetState($SClist, $GUI_FOCUS) else if $accessibilitymode = 1 then speak(str("listEmpty")) endIf endIf
      Is there any way to solve this problem, please?
      am waiting your answers...
      Greetings to All
    • AndreasNWWWWW
      By AndreasNWWWWW
      Hi, i'm just curious is there a way to sort an ini file after largest first?
      my inifiles writes itself like this
      14=500
      13=GREY
      12=500
      11=600
      10=600
      9=600
      8=700
      7=700
      5=600
      3=600
      2=800
      1=700
      15=GREY
      4=GREY
       
      but is there a way so i can get it sortet 
      15
      14
      13
      12 
      etc?
    • Broihon
      By Broihon
      Hey guys,

      I ran into a problem when I wanted to delete items of a listview using the delete key. My approach is to register my own WndProc for the listview and then filter the $WM_GETDLGCODE msg and then call the original WndProc.
      That works like a charm. The problem is that when the listview gets redrawn it somehow ends up in an infinite loop. The listview is suddenly emtpy and I can't interact with any controls of the GUI at all. Here's the code:
       
      #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WinAPI.au3> $h_GUI = GUICreate("Test", 200, 200, 350, 350) $h_LV = GUICtrlCreateListView("Col 1|Col 2|Col 3", 0, 0, 200, 200) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 0) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 1) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 0) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 1) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 0) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 1) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 0) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 1) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 2) $h_LV_NewWndProc = DllCallbackRegister("WndProc_LV", "int", "hwnd;uint;wparam;lparam") $g_LV_OldWndProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($h_LV), $GWL_WNDPROC, DllCallbackGetPtr($h_LV_NewWndProc)) GUISetState(@SW_SHOW) Func WndProc_LV($hWnd, $uMsg, $wParam, $lParam) Return _WinAPI_CallWindowProc($g_LV_OldWndProc, $hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>WndProc_GUI Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCallbackFree($h_LV_NewWndProc) As you can see I'm doing nothing in the WndProc of the listview. I'm simply calling the original WndProc. This still "freezes" when I mess with the width of the columns or in the original project when I add more items that they don't fit in the listview and I have to scroll. If I don't do that it's working fine.
    • AndreasNWWWWW
      By AndreasNWWWWW
      Hi, i'm curious if this is even possible, i want to do an action if the ini file contains current values under a section.
      for my test i'm looking for 100,200,300,400,500
      and if any of those excits i want to pop a msgbox with the number in the section.
      i can in my example find one, but it does not check everyone. why?  what am i missing?
      Local $iscore810[5] = [100,200,300,400,500] Local $iMax800 = 5 While 1 ;~     Send("{pause}") ;;func les ini fil     $var = IniReadSection("Area.ini", "modus")     If @error Then         MsgBox(4096, "Error", "Unable to read section.")     Else          For $number = 1 To $var[0][0] If $var[$number][1] == $iscore810[3] Then       MsgBox($MB_SYSTEMMODAL, "FAnt den på", $var[$number][0], 5) EndIf                       Next     EndIf     exit WEnd  
    • c.haslam
      By c.haslam
      I have
      Local $idListview = GUICtrlCreateListView("",8,8,@DesktopWidth/2-16,@DesktopHeight-150,$LVS_SHOWSELALWAYS, _ $LVS_EX_INFOTIP) Local $hListView = GUICtrlGetHandle($idListview) _GUICtrlListView_InsertColumn($hListview, 0, "Filename", 400) _GUICtrlListView_InsertColumn($hListview, 1, "Ext", 50) _GUICtrlListView_InsertColumn($hListview, 2, "Size",70) _GUICtrlListView_InsertColumn($hListview, 3, 'Date time',100) _GUICtrlListView_InsertColumn($hListview, 4, "Path", 385) _GUICtrlListView_InsertColumn($hListview, 5, "sizeInt", 0) _GUICtrlListView_JustifyColumn($hListview, $kSize,1) ; right align then further on
      While True $sFnamExt = FileFindNextFile($iSrch) If @error Then ExitLoop EndIf $sAtts = FileGetAttrib($sPath&'\'&$sFnamExt) If StringInStr($sAtts,'D') Then If $sFnamExt<>'$RECYCLE.BIN' Then $sDirs &= '?'&$sPath&'\'&$sFnamExt EndIf Else $p = StringInStr($sFnamExt,'.',0,-1) ; last If $p=0 Then $sFnam = $sFnamExt $sExt = '' Else $sFnam = StringLeft($sFnamExt,$p-1) $sExt = StringTrimLeft($sFnamExt,$p) EndIf _GUICtrlListView_AddItem($hListview,$sFnam,-1,_GUICtrlListView_GetItemCount($hListview)+1000) _GUICtrlListView_AddSubItem($hListview,$nItem,$sExt,$kExt) $nSize = FileGetSize($sPath&'\'&$sFnamExt) $sSize = AddThousandsSeparator($nsize) _GUICtrlListView_AddSubItem($hListview,$nItem,$sSize,$kSize) _GUICtrlListView_AddSubItem($hListview,$nItem,$nsize,$kSizeInt) $nTotBytes += $nSize $a1 = FileGetTime($sPath&'\'&$sFnamExt,$FT_MODIFIED,$FT_ARRAY) $t = $a1[0]&'-'&$a1[1]&'-'&$a1[2]&' '&$a1[3]&':'&$a1[4] _GUICtrlListView_AddSubItem($hListview,$nItem,$t,$kDateTime) _GUICtrlListView_AddSubItem($hListview,$nItem,$sPath,$kPath) If $gSQL Then $s = "Insert into tbl values ("&_SQLite_Escape($sFnam)&","&_SQLite_Escape($sExt)&",'"& _ $sSize&"','"& _ $t&"',"&_SQLite_Escape($sPath)&","&$nSize&")" _SQLite_Exec(-1,$s) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf EndIf EndIf WEnd FileClose($iSrch) You will see that I heeded the advice in Help > _GUICtrlListView_AddItem: "As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended."
      (It's unfortunate that the Example does not heed this advice. OK, it doesn't need to because there are no other controls, but still --- it would help neophytes if it did. Also to me _GUICtrlListView_AddItem is not native because it is a UDF. Confused?)
      My script then does a sort using SQLite, and updates the ListView:
      Local $hQuery Local $colNames = ['fnam','ext','nsize','dateTime','path','SizeInt'] Local $s = "Select * FROM tbl ORDER BY "&$colNames[$ncol]&';' _SQLite_Query(-1,$s, $hQuery) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf Local $aRow[$kSizeInt+1] Local $iItem=-1 While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf $iItem += 1 For $i = $kFnam To $kSizeInt _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default) Next WEnd This works, but I had earlier coded
      _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default,$iItem+1000) because the same advice is in the Help for this function.
      So my care in specifying $param back-fired! What am I not understanding?
      The only difference in what works is that the $param parameter is defaulted.
×