Jump to content

Having problems with If/Then Statements...


Recommended Posts

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

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 by megablox

"The story of a blade is linked in Blood." 

―Yasuo

 

Link to comment
Share on other sites

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

maybe you should put so.

If $BEvent = 1 Then Buyers() ; to call the Function Correctly.
Link to comment
Share on other sites

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 by megablox

"The story of a blade is linked in Blood." 

―Yasuo

 

Link to comment
Share on other sites

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

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

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