Sign in to follow this  
Followers 0
Alek

Assert

2 posts in this topic

thought it might come in handy when debuging :)

was kinda surprised it worked :)

Global Const $Notify_Assert_Error = True

_Assert("B" == "B")
MsgBox(0,"Oh hai", "Yay!!! made it past first assertion")
$x = 23
_Assert($x > 12)
MsgBox(0, "Oh hai","Wow, we got past the seacond one as well :D")
$y = 13
_Assert($x < $y)
MsgBox(0, "Oh noes","Oh hai their, how did you make it this far??")


Func _Assert($test, $line = @ScriptLineNumber) ;@ScriptLineNumber does not work when compiled :(
    if Not $Notify_Assert_Error  Then
        Return
    Elseif Not $test Then
        if MsgBox(16 + 4, "Assertion error @ " & $line,"An assertion error have accured, would like to stop the script?" & @CRLF & _
        "Press 'Yes' to exit or press 'No' to ignore the error") = 6 Then
            Exit
        EndIf
    EndIf
EndFunc

[font="Impact"]Never fear, I is here.[/font]

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