assert

Richmond richmondmathewson at gmail.com
Sun Feb 23 08:31:04 EST 2014


Right; so here I am on a Sunday afternoon feeling
suitably postprandial . . . and looking at the notes for 6.6 dp1
and playing around with ASSERT

Set up a stack with a button with this script:

on mouseUp
    assert 1 is 2
end mouseUp

as per notes.

SO? Where is any sort of result????

tried this script:

on mouseUp
    put assert (1 is 2) into fld "fOUT"
end mouseUp

that one "threw a bluey"

as did:

on mouseUp
    put assert (1 is 2)
end mouseUp

So, I made another button with this script:

on mouseUp
    if 1 is 2 then
       put "Yup" into fld "fOUT"
    else
       put "Nope" into fld "fOUT"
       end if
end mouseUp

which worked perfectly.

---------------------------------------------

SO; assert is meant to be a way to check for runtime errors

[which in my example above it certainly does NOT look like]

WHERE is one expected to see "fails" or "succeeds"

or, how does one know if assert has either failed or succeeded?

--------------------------------------------

Why not just run one's original script and see it the da*n things works?

-------------------------------------------

"if the condition fails, then an assertError message is sent to the 
object containing the
command"

Where does the programmer see the assertError message?

------------------------------------------

Richmond.




More information about the use-livecode mailing list