Sign in to follow this  
Followers 0
Champak

Stop loop problem

5 posts in this topic

#1 ·  Posted (edited)

I have message box inside an "If" statement where I have a "yes" or "no" question. Upon "no" the function is suppose to stop...but the GUI should remain open. If I put "exit" --- which is the only way I know how to stop a function --- the GUI exits. If I put in "EndLoop", it wont allow it. How do I do this?

Edit:

I solved the problem a different way, but am still interested in a specific solution for this if there is one.

Edited by Champak

Share this post


Link to post
Share on other sites



Use Return to exit from a function.

:)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

example :

Func _check_msgbox_overwrite($file,$dest,$type)
    if msgbox(1+256+48,"The destination is newer","Do you want to replace the newer file :" _
       &@lf&@lf&_gettime($dest&$type&$fname)&" "&$dest&$type&$fname&" "&@lf&@lf& _
       "by this older file ?"&@lf&@lf&_gettime($file)&" "&$file) = 1 then
        return 1
    Else
        return 0
    EndIf
EndFunc;==>_check_msgbox_overwrite
Edited by Gyzmok

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

Share this post


Link to post
Share on other sites

Thanks. Now instead of doing whay you did Gyzmok, I just put ";" to continue through for yes and "Return" for no. Is there a reason you did return 1 and 0? Or is that just "proper" coding?

Share this post


Link to post
Share on other sites

Gyzmok is returning a boolean condition with the example. 0 is a false condition, and not 0 is true. Same concept can be regarded with strings as "" is a false condition, and "something" is a true condition. The keywords If and Then will test the condition. If you expect a string return, then the latter could be chosen as a suitable return value to use.

This may help with some understanding:

_Check( _0() )
_Check( _1() )
_Check( _2() )
_Check( _3() )

Func _Check($condition)
    ; Check the $condition
    If $condition Then
        MsgBox(0, $condition, 'True condition')
    Else
        MsgBox(0, $condition, 'False condition')
    EndIf
EndFunc

Func _0()
    ; Return a false numerical condition
    Return 0
EndFunc

Func _1()
    ; Return a true numerical condition
    Return 1
EndFunc

Func _2()
    ; Return a false string condition
    Return ""
EndFunc

Func _3()
    ; Return a true string condition
    Return "string"
EndFunc

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