kpu Posted December 14, 2005 Posted December 14, 2005 Since there doesn't seem to be anyone in the GUI forum, I'm posting here to hopefully get more of a speedy result. :"> Please see topic http://www.autoitscript.com/forum/index.php?showtopic=19067 http://www.kpunderground.com
kpu Posted December 14, 2005 Author Posted December 14, 2005 I think I'm getting closer. Can someon look at this? I get an error on line 48: For $i = 1 To $var[0][0] For $i = 1 To $var^ ERROR expandcollapse popup#include <GuiConstants.au3> #include <file.au3> #include <array.au3> Dim $e, $i, $var, $file, $TreeView, $TreeView1, $var2, $TreeView2 Dim $TreeView3, $test1, $varx Dim $var, $file, $x $file = "logfile1.ini" If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("Form2", 420, 331, 430,346 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ;_IniReadInfo() _IniGetSectionNames() GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _IniGetSectionNames() $varx = IniReadSectionNames($file) If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $x = 1 To $varx[0] MsgBox(4096, "", $varx[$x]) _IniReadInfo() Next EndIf EndFunc Func _IniReadInfo() ;MsgBox(32,"VarX","Varx = " & $varx[$x]) $var = IniReadSection($file,$varx[$x]) $TreeView1 = GUICtrlCreateTreeView(16, 16, 353, 217) If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else $TreeView2 = GUICtrlCreateTreeViewitem("KPU-24",$TreeView1) For $i = 1 To $var[0][0] GUICtrlCreateTreeViewItem($var[$i][0], $TreeView2) MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF );& "Value: " & $var[$i][1]) Next EndIf EndFunc http://www.kpunderground.com
dragonrider Posted December 16, 2005 Posted December 16, 2005 (edited) I think I'm getting closer. Can someon look at this? I get an error on line 48: expandcollapse popup#include <GuiConstants.au3> #include <file.au3> #include <array.au3> Dim $e, $i, $var, $file, $TreeView, $TreeView1, $var2, $TreeView2 Dim $TreeView3, $test1, $varx Dim $var, $file, $x $file = "logfile1.ini" If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("Form2", 420, 331, 430,346 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ;_IniReadInfo() _IniGetSectionNames() GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _IniGetSectionNames() $varx = IniReadSectionNames($file) If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $x = 1 To $varx[0] MsgBox(4096, "", $varx[$x]) _IniReadInfo() Next EndIf EndFunc Func _IniReadInfo() ;MsgBox(32,"VarX","Varx = " & $varx[$x]) $var = IniReadSection($file,$varx[$x]) $TreeView1 = GUICtrlCreateTreeView(16, 16, 353, 217) If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else $TreeView2 = GUICtrlCreateTreeViewitem("KPU-24",$TreeView1) For $i = 1 To $var[0][0] GUICtrlCreateTreeViewItem($var[$i][0], $TreeView2) MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF );& "Value: " & $var[$i][1]) Next EndIf EndFunc Try the code below. I changed around a few things & cleaned it up somewhat (removed variables that weren't being used etc.) so I could understand what you were doing. Hope you don't mind. java script:emoticon('', 'smid_8') smilie Your main problem was that you were trying to use a local variable "$x" (now $i_SectionIndex) from the _IniGetSectionNames() function in the _IniReadInfo() function. The _IniReadInfo() function doesn't know anything about this variable & creates it on 1st use & assigns a null value to it. So nothing was being added to the treeview because of it. I also changed the "kpu-24" entry to the name of each section name by replacing it with $varx[$i_SectionIndex]. This seems to be more informative as far as the displaying of the .INI file is concerned. HTH Dragonrider Here's the code. expandcollapse popup#include <GuiConstants.au3> #include <file.au3> #include <array.au3> Dim $msg = "" Dim $file = "logfile1.ini" Dim $TreeView = _CreateGUI() _IniGetSectionNames( $file, $TreeView ) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _IniGetSectionNames( $file, $TreeView ) Local $varx = IniReadSectionNames( $file ) If @error Then Local $RetCode = MsgBox(5000, "", "Error occured, probably no INI file.") If( $RetCode = 6 ) Then Exit() EndIf Else For $i_SectionIndex = 1 To $varx[0] MsgBox(4096, "", $varx[$i_SectionIndex]) _IniReadInfo( $file, $varx, $TreeView, $i_SectionIndex ) Next EndIf EndFunc Func _IniReadInfo( $file, $varx, $TreeView, $i_SectionIndex ) ;MsgBox(32,"VarX","Varx = " & $varx[$i_SectionIndex]) Local $TreeView2 = GUICtrlCreateTreeViewitem($varx[$i_SectionIndex],$TreeView ) Local $var = IniReadSection($file,$varx[$i_SectionIndex]) If @error Then ; MsgBox(4096, "", "Error occured, probably no INI file.") Return Else For $i = 1 To $var[0][0] GUICtrlCreateTreeViewItem($var[$i][0] & " = " & $var[$i][1], $TreeView2) MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF );& "Value: " & $var[$i][1]) Next EndIf EndFunc Func _CreateGUI() If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("Form2", 420, 331, 430,346 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) Return GUICtrlCreateTreeView(16, 16, 353, 217) EndFuncTreeview_From_INI.au3 Edited December 16, 2005 by dragonrider
dragonrider Posted December 16, 2005 Posted December 16, 2005 Try the code below. I changed around a few things & cleaned it up somewhat (removed variables that weren't being used etc.) so I could understand what you were doing. Hope you don't mind. java script:emoticon('', 'smid_8') smilie Your main problem was that you were trying to use a local variable "$x" (now $i_SectionIndex) from the _IniGetSectionNames() function in the _IniReadInfo() function. The _IniReadInfo() function doesn't know anything about this variable & creates it on 1st use & assigns a null value to it. So nothing was being added to the treeview because of it. I also changed the "kpu-24" entry to the name of each section name by replacing it with $varx[$i_SectionIndex]. This seems to be more informative as far as the displaying of the .INI file is concerned. HTH Dragonrider Here's the code. expandcollapse popup#include <GuiConstants.au3> #include <file.au3> #include <array.au3> Dim $msg = "" Dim $file = "logfile1.ini" Dim $TreeView = _CreateGUI() _IniGetSectionNames( $file, $TreeView ) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _IniGetSectionNames( $file, $TreeView ) Local $varx = IniReadSectionNames( $file ) If @error Then Local $RetCode = MsgBox(5000, "", "Error occured, probably no INI file.") If( $RetCode = 6 ) Then Exit() EndIf Else For $i_SectionIndex = 1 To $varx[0] MsgBox(4096, "", $varx[$i_SectionIndex]) _IniReadInfo( $file, $varx, $TreeView, $i_SectionIndex ) Next EndIf EndFunc Func _IniReadInfo( $file, $varx, $TreeView, $i_SectionIndex ) ;MsgBox(32,"VarX","Varx = " & $varx[$i_SectionIndex]) Local $TreeView2 = GUICtrlCreateTreeViewitem($varx[$i_SectionIndex],$TreeView ) Local $var = IniReadSection($file,$varx[$i_SectionIndex]) If @error Then ; MsgBox(4096, "", "Error occured, probably no INI file.") Return Else For $i = 1 To $var[0][0] GUICtrlCreateTreeViewItem($var[$i][0] & " = " & $var[$i][1], $TreeView2) MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF );& "Value: " & $var[$i][1]) Next EndIf EndFunc Func _CreateGUI() If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("Form2", 420, 331, 430,346 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) Return GUICtrlCreateTreeView(16, 16, 353, 217) EndFunc I found 2 bugs in the code I posted. 1. It said that the .INI file may not exist when there were no key/value pairs in a section. and 2. It didn't display the key's value. Both have been corrected and the original code above has been edited. Regards Dragonrider P.S. It now reads my win.ini just fine when I put it into the same folder as the script & rename it to "Logfile1.ini".
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