Jump to content

Ending A Function Inside An If/then Statement


Recommended Posts

Hello all,

I am getting an error while trying to run something like this:

$btnProcess = GUICtrlCreateButton("Process", 30, 277, 141, 37)

GUICtrlSetOnEvent($btnProcess, "Process")

Func Process()

If NOT FileExists ( $Location ) Then

MsgBox (48, "Sorry...", "The folder you specified doesn't seem to exist.", 0)

EndFunc

EndIf

EndFunc

Basically, I want the function to end if the folder doesn't exist and go back to the (OnEvent) idle loop. But it keeps telling me that there is no EndIf, because it is counting the EndFunc inside the If/Then statement as the end of the function. Is there any other way to just end the function at that point without this problem?

btw, I tried making the If statement a single line statement... like

If NOT FileExists ( $Location) Then EndFunc

But then it tells me that there is an If with no corresponding Then...

˙˙˙ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן

Link to comment
Share on other sites

why do you have two endfunction?

Func Process()

If NOT FileExists ( $Location ) Then

    MsgBox (48, "Sorry...", "The folder you specified doesn't seem to exist.", 0)
    Idle(); whatever function you want here.

EndIf

EndFunc

this should do it

Edited by Hello12345
Link to comment
Share on other sites

If NOT FileExists ( $Location ) Then

MsgBox (48, "Sorry...", "The folder you specified doesn't seem to exist.", 0)

;change made here

idle()

EndIf

make idle() a func with you OnIdle loop inside, then jsut call that when u need to get back to it.

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

if you want it to exit the function use this

$btnProcess = GUICtrlCreateButton("Process", 30, 277, 141, 37)
GUICtrlSetOnEvent($btnProcess, "Process")

Func Process()
    If NOT FileExists ( $Location ) Then
        MsgBox (48, "Sorry...", "The folder you specified doesn't seem to exist.", 0)
        Return
    EndIf
EndFunc

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
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...