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

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • 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

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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



CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • 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

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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?
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • 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

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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
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 »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • 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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: script wizard and assert()
« Reply #8 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
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: 5910
  • 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

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
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
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl