Code::Blocks Forums

User forums => Embedded development => Topic started by: LETARTARE on June 11, 2013, 10:43:50 am

Title: script wizard and assert()
Post by: LETARTARE on June 11, 2013, 10:43:50 am
hello,
in the Squirrel 3.0 reference manuel found :

Quote
assert(exp)
throws an exception if exp is null

is that this function is available in the wizard scripts ?

if not, how to raise an exception in a wizard script?

thank you.
Title: Re: script wizard and assert()
Post by: oBFusCATed on June 11, 2013, 10:46:09 am
As far as I know we're still using squirrel 2.x, so you have to check its manual.
Title: Re: script wizard and assert()
Post by: LETARTARE on June 11, 2013, 10:57:31 am
thank you for the answer.

Squirrel 2.2  is identical ...

Quote
assert(exp)
throws an exception if exp is null



Title: Re: script wizard and assert()
Post by: oBFusCATed on June 11, 2013, 11:00:33 am
OK. Have you tried it?
What do you expect to happen?
Who is going to catch it?
Title: Re: script wizard and assert()
Post by: LETARTARE on June 11, 2013, 11:08:15 am
Quote
OK. Have you tried it?
yes with my configuration
Quote
What do you expect to happen?
crash Code::Blocks !!!
Quote
Who is going to catch it?
I do not know, this is why I ask questions?
Title: Re: script wizard and assert()
Post by: oBFusCATed on June 11, 2013, 12:07:22 pm
crash Code::Blocks !!!
Why?
But I'm sure it won't happen, probably you'll get an error in the log or it will be silently ignored.
Title: Re: script wizard and assert()
Post by: LETARTARE on June 11, 2013, 12:24:55 pm
I think I misunderstood
Quote
What do you expect to happen?
in fact, this is what happened during the test
Code
local board = null;
assert(board)

This exception should be recovered by "Code::Blocks" to notify the user ?
This is not the case.
Title: Re: script wizard and assert()
Post by: oBFusCATed on June 11, 2013, 01:11:13 pm
I don't understand sorry. Please explain better or provide a sample script.
Title: Re: script wizard and assert()
Post by: ollydbg on June 11, 2013, 04:02:43 pm
Code
local board = null;
assert(board)
This exception should be recovered by "Code::Blocks" to notify the user ?
I tried the code in "Scripting console", there will pop an error message box, and no crash of C::B.
Quote
Welcome to the script console!
> local board = null;
> assert(board)

AN ERROR HAS OCCURED [the index 'board' does not exist]

CALLSTACK
*FUNCTION [main()] ScriptConsole line [1]

LOCALS
[this] TABLE

AN ERROR HAS OCCURED [the index 'board' does not exist]

CALLSTACK
*FUNCTION [main()] ScriptConsole line [1]

LOCALS
[this] TABLE
Title: Re: script wizard and assert()
Post by: ollydbg on June 11, 2013, 04:11:00 pm
If I add the code in a project wizard script, then I see a message box said: script error has occurred, please press yes to see the exact errors.

Then I click Yes, there will be a dialog to show the detailed error messages. Still no crash of C::B.
Title: Re: script wizard and assert()
Post by: LETARTARE on June 11, 2013, 04:37:56 pm
@ollydbg
thank you very much for taking the time to check these two lines of code.

So I try on the other machine with the same configuration, and I confirm your results: we get the warning messages.

I incriminates my first PC, I'll check.

Thank you again for the constructive responses