enigmaforceiv Posted September 2, 2012 Share Posted September 2, 2012 If $BEvent = 1 Then Func Buyers() Opt("GUICoordMode", 3) GUISetFont(9, 1000, 0, $font) Sleep(10) $FileList = _FileListToArray("C:\Dropbox\Century21\Client Database\Buyers", "*", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder In $FileList ; Loop over folders found. GUICtrlSetData($list, $folder) Next EndIf EndFunc I keep getting this error: "Func Buyers() Error: "If" statement has no matching "EndIf" statement." What am I doing wrong? Link to comment Share on other sites More sharing options...
Khryus Posted September 2, 2012 Share Posted September 2, 2012 (edited) EndIf should be outside the function If $BEvent = 1 Then Func Buyers() Opt("GUICoordMode", 3) GUISetFont(9, 1000, 0, $font) Sleep(10) $FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder In $FileList ; Loop over folders found. GUICtrlSetData($list, $folder) Next EndFunc EndIf Edited September 2, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
FireFox Posted September 2, 2012 Share Posted September 2, 2012 Hi, You have swapped EndIf and EndFunc, furthemore you can not write a func inside something (while, if). Here you go : If $BEvent = 1 Then Buyers() ;call the func EndIf Func Buyers() ;func outside Opt("GUICoordMode", 3) GUISetFont(9, 1000, 0, $font) Sleep(10) $FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder In $FileList ; Loop over folders found. GUICtrlSetData($list, $folder) Next EndFunc ;==>Buyers Br, FireFox. Link to comment Share on other sites More sharing options...
Danyfirex Posted September 2, 2012 Share Posted September 2, 2012 maybe you should put so. If $BEvent = 1 Then Buyers() ; to call the Function Correctly. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Author Share Posted September 2, 2012 Thanks all! Also, $BEvent is tied to a button, however, even though I don't press the button to call the function, the function is already executed - even though I didn't click any buttons. How can I tell the script to not execute a function unless it's called on? Link to comment Share on other sites More sharing options...
Khryus Posted September 2, 2012 Share Posted September 2, 2012 (edited) If $BEvent is the variable storing the controlID (which is returned by a GUICtrlCreate... function) of the button, then do this: Opt("GUIOnEventMode", 1) ; put this at the top of your script GUICtrlSetOnEvent(-1, "Buyers") ; put this right after $BEvent is declared That will trigger the function whenever the button is clicked Edited September 2, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Author Share Posted September 2, 2012 Then the IF/Then statements aren't needed, correct? Link to comment Share on other sites More sharing options...
Khryus Posted September 2, 2012 Share Posted September 2, 2012 Correct "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Author Share Posted September 2, 2012 I'm guessing that my problem isn't an If/then statement, but more of a question on how can I turn "on and off" a command in my script. Generally, what I'm trying to do is have the button call a function that lists files in a specific directory. However, instead of listing files in each directory separately, it adds to the list of already found files. What I'm trying to do is have that list "refresh" into the new list. Link to comment Share on other sites More sharing options...
Khryus Posted September 2, 2012 Share Posted September 2, 2012 If you want to clear the list before adding the new files, then set the list's data to an empty string ("") before adding more data "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Author Share Posted September 2, 2012 Do you think a loop will be necessary? $BuyerV = GUICtrlCreateButton("Buyers", 50, 50, 100, 30) ;creates buttons $BEvent = GUICtrlSetOnEvent($BuyerV, "Buyers") ;assigns event to button $list = GUICtrlCreateList("", 200, 50, 300, 290) ;creates a universal list window - however all files are displayed here instead of erased. GUICtrlSetData($list, "") GUISetState(@SW_SHOW) Func Buyers() Opt("GUICoordMode", 3) GUISetFont(9, 1000, 0, $font) Sleep(10) $FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string _ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index For $folder In $FileList ; Loop over folders found. GUICtrlSetData($list, $folder) Next EndFunc Link to comment Share on other sites More sharing options...
FireFox Posted September 2, 2012 Share Posted September 2, 2012 Do you think a loop will be necessary? Yes, you need a main loop between the gui and the funcs. Here you go : While 1 Sleep(1000) ;less cpu ;add code here to be executed everytime. WEnd Br, FireFox. Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Author Share Posted September 2, 2012 Wow, that loop saved up so much cpu! Thanks for all your help guys, everything is working as expected now! 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