Sign in to follow this  
Followers 0
level20peon

(solved) EndFunc if... ?

4 posts in this topic

#1 ·  Posted (edited)

How would one implement something like

test()

Func test()
    if WinExists('windowXYZ')Then
        MsgBox(0,'','window exists')
        EndFunc
    EndIf

    MsgBox(0,'',"window doesn't exist")

EndFunc

It throw's an error "missing EndIf" if the windowXYZ exists.

Edited by level20peon

Share this post


Link to post
Share on other sites



Just use Return instead of EndFunc in the if statement


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

EndFunc acually tells the interpreter that the section dedicated to the punction's code is finished

to exit a function you must use Return

you can use return or return + a value

$a=_func1()
$b=_func2()

msgbox(0,"",$B)
msgbox(0,"",_func2()) ;they will return the same thing =)

Func _func1()
if 1=1 then 
 msgbox(0,"","This will return nothing")
 return
endif

msgbox(0,"","This Code Won't Be Executed because of the return!")
endfunc

Func _func2()
 msgbox(0,"","This will return some text")
 return "some text"
 msgbox(0,"","This Code Won't Be Executed because of the return!")
endfunc

I hope I was clear :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Great, thanks to both of you.

Edited by level20peon

Share this post


Link to post
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
Sign in to follow this  
Followers 0