russell Posted November 15, 2011 Share Posted November 15, 2011 I started with one of my old piece of a code expandcollapse popupGlobal $reportfile = "C:\Windows\Temp\" Global $box[7] #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 492, 395, -903, 134) $field1gui = GUICtrlCreateCombo("", 16, 32, 81, 25) GUICtrlSetData(-1, "yes|no") $field2gui = GUICtrlCreateCombo("", 16, 56, 81, 25) GUICtrlSetData(-1, "yes|no") $field3gui = GUICtrlCreateCombo("", 16, 80, 81, 25) GUICtrlSetData(-1, "yes|no") $field4gui = GUICtrlCreateCombo("", 16, 104, 81, 25) GUICtrlSetData(-1, "yes|no") $field5gui = GUICtrlCreateCombo("", 16, 128, 81, 25) GUICtrlSetData(-1, "yes|no") $field6gui = GUICtrlCreateCombo("", 16, 152, 81, 25) GUICtrlSetData(-1, "yes|no") $field7gui = GUICtrlCreateCombo("", 16, 176, 81, 25) GUICtrlSetData(-1, "yes|no") $field8gui = GUICtrlCreateCombo("", 16, 200, 81, 25) GUICtrlSetData(-1, "yes|no") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep (10000) ExitLoop WEnd $box1=(GUICtrlRead($field1gui) ) $box2=(GUICtrlRead($field2gui) ) $box3=(GUICtrlRead($field3gui) ) $box4=(GUICtrlRead($field4gui) ) $box5=(GUICtrlRead($field5gui) ) $box6=(GUICtrlRead($field6gui) ) $box7=(GUICtrlRead($field7gui) ) $box8=(GUICtrlRead($field8gui) ) If $box1 = "yes" Then FileWrite($reportfile & "acc1.txt", "account1") EndIf If $box2 = "yes" Then FileWrite($reportfile & "acc2.txt", "account2") EndIf If $box3 = "yes" Then FileWrite($reportfile & "acc3.txt", "account3") EndIf If $box4 = "yes" Then FileWrite($reportfile & "acc4.txt", "account4") EndIf If $box5 = "yes" Then FileWrite($reportfile & "acc5.txt", "account5") EndIf If $box6 = "yes" Then FileWrite($reportfile & "acc6.txt", "account6") EndIf If $box7 = "yes" Then FileWrite($reportfile & "acc7.txt", "account7" ) EndIf If $box8= "yes" Then FileWrite($reportfile & "acc8.txt", "account8") EndIf Now that seems to work but i wanted to learn arrays and clean it up so i made the below expandcollapse popupGlobal $reportfile = "C:\Windows\Temp\" Global $box[7] #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 492, 395, -903, 134) $field1gui = GUICtrlCreateCombo("", 16, 32, 81, 25) GUICtrlSetData(-1, "yes|no") $field2gui = GUICtrlCreateCombo("", 16, 56, 81, 25) GUICtrlSetData(-1, "yes|no") $field3gui = GUICtrlCreateCombo("", 16, 80, 81, 25) GUICtrlSetData(-1, "yes|no") $field4gui = GUICtrlCreateCombo("", 16, 104, 81, 25) GUICtrlSetData(-1, "yes|no") $field5gui = GUICtrlCreateCombo("", 16, 128, 81, 25) GUICtrlSetData(-1, "yes|no") $field6gui = GUICtrlCreateCombo("", 16, 152, 81, 25) GUICtrlSetData(-1, "yes|no") $field7gui = GUICtrlCreateCombo("", 16, 176, 81, 25) GUICtrlSetData(-1, "yes|no") $field8gui = GUICtrlCreateCombo("", 16, 200, 81, 25) GUICtrlSetData(-1, "yes|no") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep (10000) ExitLoop WEnd $box[0]=(GUICtrlRead($field1gui) ) $box[1]=(GUICtrlRead($field2gui) ) $box[2]=(GUICtrlRead($field3gui) ) $box[3]=(GUICtrlRead($field4gui) ) $box[4]=(GUICtrlRead($field5gui) ) $box[5]=(GUICtrlRead($field6gui) ) $box[6]=(GUICtrlRead($field7gui) ) ;~ $box[7]=(GUICtrlRead($field8gui) ) If $box = "yes" Then FileWrite($reportfile & "acc" & $box & ".txt", "account" & $box) EndIf Now the problem im having is somewhere on the $box[7] it has an error so i silenced it and exit code is 0...Hurray......but no output Am i structuring this wrong? I tried using the help but i think i get more lost than i start. muppet hands are so soft :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2011 Moderators Share Posted November 15, 2011 russell, If you want to use arrays then you need to learn about loops too! Take a look at this - I think it mirrors what you were trying to do, but with rather more compact code: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $reportfile = "C:WindowsTemp" Global $box[8], $field[8] #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 492, 395, 903, 134) ; Use an array to hold the combo ControlIDs as well - then we can loop through them For $i = 0 To 7 $field[$i] = GUICtrlCreateCombo("", 16, 32 + (24 * $i), 81, 25) GUICtrlSetData(-1, "yes|no") Next GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(10000) ExitLoop WEnd ; Now we can loop through the combos and read them For $i = 0 To 7 $box[$i] = GUICtrlRead($field[$i]) If $box[$i] = "yes" Then ; Not quite sure what you wanted to write to the file - you should be able to see what the various options are from this. MsgBox(0, "Writing", $reportfile & "acc" & $i & ".txt" & @CRLF & "account" & $box[$i]) EndIf Next Please ask if you have any questions. M23 russell 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
water Posted November 15, 2011 Share Posted November 15, 2011 How about this. expandcollapse popupGlobal $reportfile = "C:\Temp\" Global $box #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 492, 395) $field1gui = GUICtrlCreateCombo("", 16, 32, 81, 25) GUICtrlSetData(-1, "yes|no") $field2gui = GUICtrlCreateCombo("", 16, 56, 81, 25) GUICtrlSetData(-1, "yes|no") $field3gui = GUICtrlCreateCombo("", 16, 80, 81, 25) GUICtrlSetData(-1, "yes|no") $field4gui = GUICtrlCreateCombo("", 16, 104, 81, 25) GUICtrlSetData(-1, "yes|no") $field5gui = GUICtrlCreateCombo("", 16, 128, 81, 25) GUICtrlSetData(-1, "yes|no") $field6gui = GUICtrlCreateCombo("", 16, 152, 81, 25) GUICtrlSetData(-1, "yes|no") $field7gui = GUICtrlCreateCombo("", 16, 176, 81, 25) GUICtrlSetData(-1, "yes|no") $field8gui = GUICtrlCreateCombo("", 16, 200, 81, 25) GUICtrlSetData(-1, "yes|no") $buttonGO = GUICtrlCreateButton("Go", 16, 230, 81, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonGo Process() EndSwitch WEnd Func Process() $iIndex = 1 For $field = $field1gui To $field8gui $box = (GUICtrlRead($field)) If $box = "yes" Then FileWrite($reportfile & "acc" & $iIndex & ".txt", "account" & $iIndex) $iIndex += 1 Next EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
russell Posted November 15, 2011 Author Share Posted November 15, 2011 I love how you guys can do that so fast I cant look at your examples and to a degree understand through trial and errror how you did it but get lost quick when i take more advanced steps. I guess im thinking i don't have a foundation. I thought loops where (while,wend,exitloop) is that not the extent of loops? maybe i missed something there too If there a good place or tutorial for me to start? muppet hands are so soft :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2011 Moderators Share Posted November 15, 2011 russell,If there a good place or tutorial for me to start?How about the Help file under <Language Reference - Loop Statements>? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
water Posted November 15, 2011 Share Posted November 15, 2011 Here you can find a bunch of tutorials. The Array tutorial is here.After reading the turials you still can ask what you don't understand in our example scripts and we will do our very best to explain. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
russell Posted November 15, 2011 Author Share Posted November 15, 2011 Thank you all, time to read hopefully i have a better understand next time i ask a question. Thank you muppet hands are so soft :) 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