fxg4758 0 Posted December 10, 2010 Hi. Can someone help me? I trying to read the seaction names from the file to now i much buttons to create in a form, and i want pass the field 0 for each section to each button, but i can´t see any name in the button. So, is possible to make this and sort the buttons on fly? And, how can i read the key in each section only after number 0? Thanks for any help! test.ini [bank] 0=Name to use in button 1=1|Bank|Adress 2=1|Bank|Adress [Finance] 0=Name to use in button 1=1|Person|Adress 2=1|Person|Adress 0=Name to use in button 1=1|Person|Mail 2=1|Person|Mail $optbar = IniReadSectionNames("test.ini") $varStartHeight += 5 For $x = 1 To UBound($optbar) - 1 $Button[$x] = GUICtrlCreateButton($x, $varStartHeight, 30, 55, 27) $varStartHeight += 60 Next Share this post Link to post Share on other sites
Varian 8 Posted December 10, 2010 You were pretty close. Changed Test.ini Name fields#include <GUIConstantsEx.au3> $optbar = IniReadSectionNames("test.ini") If Not IsArray($optbar) Then Exit Local $Button[UBound($optbar) - 1] $hGUI = GUICreate('Ini GUI', 10 + (130 * UBound($optbar)), 100) For $x = 1 To UBound($optbar) - 1 $var = IniReadSection("test.ini", $optbar[$x]) If @error Then ContinueLoop $X_Coord = 10 + (($x - 1) * 180) $Button[$x - 1] = GUICtrlCreateButton($var[1][1], $X_Coord, 30, 150, 30) Next GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit For $i = 0 To UBound($Button) - 1 If $Msg = $Button[$i] Then MsgBox(0, '$Msg = ' & $Msg, GuiCtrlRead($Button[$i]) & ' Pressed', 2) EndIf Next WEndTest.ini[Bank] 0=Bank button 1=1|Bank|Adress 2=1|Bank|Adress [Finance] 0=Finance button 1=1|Person|Adress 2=1|Person|Adress [Email] 0=Email button 1=1|Person|Mail 2=1|Person|Mail Share this post Link to post Share on other sites
kaotkbliss 146 Posted December 10, 2010 (edited) this should help you get closer #include <GUIConstantsEx.au3> $optbar = IniReadSectionNames(@ScriptDir&"\test.ini") $varStartHeight=0 $varStartHeight += 5 Dim $Button[4] GUICreate("Test") For $x = 1 To UBound($optbar) - 1 $Button[$x] = GUICtrlCreateButton($optbar[$x], $varStartHeight, 30, 55, 27) $varStartHeight += 60 Next GUISetState() While 1 $msg=GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd *edit* D@mn you Varian, beat me to it Edited December 10, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
fxg4758 0 Posted December 10, 2010 Thanks for quick answer! But my buttons don´t have caption that are in [sectionNames]/0=Key. Is there any wrong in the code? Regards! You were pretty close. Changed Test.ini Name fields#include <GUIConstantsEx.au3> $optbar = IniReadSectionNames("test.ini") If Not IsArray($optbar) Then Exit Local $Button[UBound($optbar) - 1] $hGUI = GUICreate('Ini GUI', 10 + (130 * UBound($optbar)), 100) For $x = 1 To UBound($optbar) - 1 $var = IniReadSection("test.ini", $optbar[$x]) If @error Then ContinueLoop $X_Coord = 10 + (($x - 1) * 180) $Button[$x - 1] = GUICtrlCreateButton($var[1][1], $X_Coord, 30, 150, 30) Next GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit For $i = 0 To UBound($Button) - 1 If $Msg = $Button[$i] Then MsgBox(0, '$Msg = ' & $Msg, GuiCtrlRead($Button[$i]) & ' Pressed', 2) EndIf Next WEndTest.ini[Bank] 0=Bank button 1=1|Bank|Adress 2=1|Bank|Adress [Finance] 0=Finance button 1=1|Person|Adress 2=1|Person|Adress [Email] 0=Email button 1=1|Person|Mail 2=1|Person|Mail Share this post Link to post Share on other sites
Varian 8 Posted December 10, 2010 Thanks for quick answer! But my buttons don´t have caption that are in [sectionNames]/0=Key. Is there any wrong in the code? Regards! You could change$Button[$x - 1] = GUICtrlCreateButton($var[1][1], $X_Coord, 30, 150, 30)to this$Button[$x - 1] = GUICtrlCreateButton($optbar[$x], $X_Coord, 30, 150, 30)I guess that's what you were asking??? Share this post Link to post Share on other sites
fxg4758 0 Posted December 11, 2010 Hi Varian. Thanks for your help. I want to count how any sections are in "test.ini", create the same number buttons and ordered them by the key 0=Name, that are in each section. And when i click in a button, call the sectionname that is associate. Is this possible? And can you tell me how if a program can have various While...WEnd at the same time? For example, this funcion is to use when i create a AnyGui and buttons inside. But, i don´t know how to call a funcion that works only when these buttons are created, because í´m afraid to use various While...WEnd. Regards. You could change$Button[$x - 1] = GUICtrlCreateButton($var[1][1], $X_Coord, 30, 150, 30)to this$Button[$x - 1] = GUICtrlCreateButton($optbar[$x], $X_Coord, 30, 150, 30)I guess that's what you were asking??? Share this post Link to post Share on other sites
Fubarable 1 Posted December 11, 2010 I want to count how any sections are in "test.ini", create the same number buttons and ordered them by the key 0=Name, that are in each section.You could create a 2-D array and read all the data into the array with each row being a section. Then _ArraySort will help you sort this array by whatever criteria you need.And when i click in a button, call the sectionname that is associate. Is this possible?what does "call the sectionname that is associate" mean?And can you tell me how if a program can have various While...WEnd at the same time? For example, this funcion is to use when i create a AnyGui and buttons inside. But, i don´t know how to call a funcion that works only when these buttons are created, because í´m afraid to use various While...WEnd. Regards.Please clarify. Share this post Link to post Share on other sites
fxg4758 0 Posted December 13, 2010 Hi. Thanks for all help you give me so far, but can you help me again. I change the way i was doing the things. The code is working in put each ini file to a tab and respective sections in to buttons, but when i click in a button, this funcion - MsgBox(0, '$Msg = ' & $Msg, GuiCtrlRead($Button[$i]) & ' Pressed', 2) - only works in the last tab. Where is my mistake? Thanks for your help! master file - index.ini - where are the ini files to pass to a tab. [bank.ini] [adress.ini] [health.ini] $optbar = IniReadSectionNames("index.ini") If Not IsArray($optbar) Then Exit _ArraySort($optbar) $hGUI = GUICreate('Ini GUI', 600,600,10,10) $varTab = GUICtrlCreateTab(10, 10, 200, 100) For $z = 1 To UBound($optbar) - 1 $optbarAreas = IniReadSectionNames($optbar[$z]) _ArraySort($optbarAreas) Local $varTabItem[uBound($optbarAreas) - 1], $Button[uBound($optbarAreas) - 1] $varTabItem[$z - 1] = GUICtrlCreateTabItem(StringTrimRight($optbar[$z],4)) For $x = 1 To UBound($optbarAreas) - 1 $var = IniReadSection($optbar[$z],$optbarAreas[$x]) If @error Then ContinueLoop $X_Coord = 10 + (($x - 1) * 180) $Button[$x - 1] = GUICtrlCreateButton($optbarAreas[$x], $X_Coord, 30, 150, 30) Next GUISetState() Next GUICtrlCreateTabItem(""); end tabitem definition GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit For $i = 0 To UBound($Button) - 1 If $Msg = $Button[$i] Then MsgBox(0, '$Msg = ' & $Msg, GuiCtrlRead($Button[$i]) & ' Pressed', 2) EndIf Next Share this post Link to post Share on other sites