Author Topic: script wizard and assert()  (Read 21655 times)

Offline LETARTARE

  • Regular
  • ***
  • Posts: 395
  • L'ami de l'homme.The friend of man.
script wizard and assert()
« 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.
C::B  : svn11911, wx-3.1.1, plugins : QtPregen-2.7.2-sdk146
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12085
    • Travis build status
Re: script wizard and assert()
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 395
  • L'ami de l'homme.The friend of man.
Re: script wizard and assert()
« Reply #2 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



C::B  : svn11911, wx-3.1.1, plugins : QtPregen-2.7.2-sdk146
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12085
    • Travis build status
Re: script wizard and assert()
« Reply #3 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 395
  • L'ami de l'homme.The friend of man.
Re: script wizard and assert()
« Reply #4 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?
C::B  : svn11911, wx-3.1.1, plugins : QtPregen-2.7.2-sdk146
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12085
    • Travis build status
Re: script wizard and assert()
« Reply #5 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline LETARTARE

  • Regular
  • ***
  • Posts: 395
  • L'ami de l'homme.The friend of man.
Re: script wizard and assert()
« Reply #6 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: [Select]
local board = null;
assert(board)

This exception should be recovered by "Code::Blocks" to notify the user ?
This is not the case.
« Last Edit: June 11, 2013, 12:27:28 pm by LETARTARE »
C::B  : svn11911, wx-3.1.1, plugins : QtPregen-2.7.2-sdk146
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12085
    • Travis build status
Re: script wizard and assert()
« Reply #7 on: June 11, 2013, 01:11:13 pm »
I don't understand sorry. Please explain better or provide a sample script.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5236
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: script wizard and assert()
« Reply #8 on: June 11, 2013, 04:02:43 pm »
Code: [Select]
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
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5236
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: script wizard and assert()
« Reply #9 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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline LETARTARE

  • Regular
  • ***
  • Posts: 395
  • L'ami de l'homme.The friend of man.
Re: script wizard and assert()
« Reply #10 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
C::B  : svn11911, wx-3.1.1, plugins : QtPregen-2.7.2-sdk146
1-Vista Business Pack 2 32bits : gcc-8.1.0,
2-OpenSuse-15.1-Leap 64bits :  gcc-7.4.1,
=> !! The messages are translated by Deepl !!