Jump to content

iniread array to display in gui


kjcdude
 Share

Recommended Posts

The goal of this script is to read a single ini file, that contains information per computer, sorted by application, then output the file into an easy to read gui. At this point, nothing further needs to be done.

Right now i have the pc number created by hand from guicreatelistview, then each application (inireadsectionames) listed in colum 1, then a 1 or 0 next to each application under each computer number, but as you can see it's pretty sloppy and only outputs the applications correctly.

#include <GUIConstants.au3>
#include <Array.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)

$file = "O:\Log\Copy of 11-24-07 8.ini"
$ssection = IniReadSectionNames($file)
;~ $list = IniRead($file, $ssection)
$v_Val1 = 001
$v_Val200 = 200
$array1 = _ArrayCreate($v_Val1, $v_Val200)
for $t = 1 to $array1[0]
$list = IniRead($file, $ssection, $array1[$t], "None")
next
$listview = GUICtrlCreateListView ("APP|001|002|003|004",10,10,200,150);,$LVS_SORTDESCENDING)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)   ; to allow drag and dropping
GUISetState()

For $i = 1 To $ssection[0]
$item = GUICtrlCreateListViewItem($ssection[$i] & "|",$listview)
next
For $x = 1 To $list[0]
GUICtrlSetData($item,"|" & $list[$x])
Next

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

part of the ini file

[Modified]
When=11/24/2007 - 17:28:27
[AOE3]
001=0
003=1
004=1
005=0
006=0
007=0
[BF2]
001=1
003=1
004=1
005=1
006=1
[BFMEII]
068=1
069=1
070=1
071=1
072=1
073=1
074=1
[BFME_ROTWK]
001=1
003=1
004=1
005=1
006=1
[COD4]
001=1
003=1
004=1
005=1
006=1
007=1
Link to comment
Share on other sites

Here is some more efficient way to do it using IniReadSection()

But it assume the same PC numbers in each section, you can tweak it to be it more general

#include <GUIConstants.au3>
#include <Array.au3>

$gui = GUICreate("ListBiew items", 400, 300, -1, -1, -1, $WS_EX_ACCEPTFILES)
$listview = GUICtrlCreateListView("APP|001|003|004|005|006|007", 10, 10, 380, 280);,$LVS_SORTDESCENDING)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)   ; to allow drag and dropping
GUISetState()

$file = "Copy of 11-24-07 8.ini" 
$ssection = IniReadSectionNames($file)

For $i = 1 To $ssection[0]
    $list = IniReadSection($file, $ssection[$i])
    $tmp = ''
        ; set title by Modified
    If $ssection[$i] = 'Modified' Then 
        WinSetTitle($gui, "", "ListView items - " & $list[1][1])
        ContinueLoop
    EndIf
        For $x = 1 To $list[0][0]
        $tmp &= $list[$x][1] & "|"
    Next
    $tmp = StringTrimRight($tmp,1)
        GUICtrlCreateListViewItem($ssection[$i] & "|" & $tmp, $listview)
Next

GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, 100)

Do
    $msg = GUIGetMsg()

    Select
        Case $msg = $listview
            MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by Zedna
Link to comment
Share on other sites

Thansk for the reply, it's heading me in the right direction.

Due to another problem with iniwrite not being able to write to the same file multiple times at the same time now each compnum has it's own file - \\nas01\Volume_1\Log\11-24-07 - 001.ini

So now i need to read around 200 files and get them all into the gui. For the input i want to figure out a way to enter the date, 11-24-07, then it will only pull those log files.

Thanks

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