Basics: Error, warning, notice

To help people find the issues in their code AmiBroker displays three kinds of messages to the users, that some people don't differentiate and/or understand. These are:

  • Errors
  • Warnings
  • Notices

There is fundamental difference between them. They differ in "strength".

An ERROR is a show-stopper. Error means that your code is wrong and requires fix. Like missing brace, incorrect argument types and so on. The formula will not run without fixing errors.

A WARNING describes either minor coding mistake or possible coding mistake. The code that has warnings still runs. It may be producing undesirable results but the execution is not interrupted. An example would be division by zero ( the code will run but will produce infinity / not-a-number), or too many Plot statements (the code will run but will be slow).

A NOTICE is just an information for the user that makes him/her aware about possible issues and/or consequences of certain settings. It does not stop execution. It also does not mean that anything is actually wrong. It just makes user aware about some facts that may impact the results. Notices are added in 6.28 and higher to prevent same questions/ mistakes that often surface due to not consulting the docs. The purpose is to raise awareness of the functionality. An example of notice is one that is reported when you use ranking functions without data padding. When user's database has holes in it, running ranking without padding may have undesirable consequences so the notice was added to make people aware of it without scratching their head and asking the same questions over and over and possibly wasting hours. Consider this as time saver and educational tool.

9 Likes

If its no big deal please add the option to select which of these appear when "verify syntax" is pressed as warnings and notices can be to many sometimes and when a error appears its hard to pass trough all of them to get to it.

Thanks

@Paul,

Functionality to set warning level exists already since AB 5.91. Just read the docs (which includes release notes).

CHANGES FOR VERSION 5.91.0 (as compared to 5.90.1)
...
AFL: new field in SetOption("WarningLevel", x ); -- allows to change warning level.
Level 1 is default for all AFL executions with exception of AFL editor and commentary where warning level is set to 4
Warning Level
1 - report only level 1 warnings (502- too much plots)
2 - report level 1 and 2 warnings (above plus assignment within conditional, division by zero, threadsleep period too long)
3 - report level 1, 2 and 3 warnings (above plus createobject/createstaticobject )
4- report all warnings (default for the AFL editor)
...

BTW, there is another functionality -> Status() function

If( Status( "actionex" ) != actionExEditVerifyFormula ) {
   // your code here which you do not want to run while verifying syntax
}

But it simply is not good practice to ignore warnings even if code still runs. A warning still means that something is not right (not being ideal/optimal/perfect).

And according to your comments your code(s) seem to be far from being optimal one(s).
Ignoring issues is not the solution. Just fix the code to remove errors and warnings. Perfect state is reached by sweat running down your body like at Niagara falls. What I mean to say is you only become good (or even perfect) by hard work. Hiding warnings is like going to plastic surgeon helping to insert silicon implants and botox to fake good shape. So personally I do not recommend using upper code methods (and I'm quite certain @Tomasz does not recommend it too).

2 Likes

@fxshrat, I think you are too cruel. There are many ways of achieving the perfect shape :grin::grinning::smile:

Synthol

2 Likes

I did not knew the functionality already exists I apologize then, thanks for pointing it out. Yes indeed I was/am more interested in doing useful stuff then optimal coding stuff and as soon as I get what I want I ignore the warnings - as long as they do not affect the results of course. for example the bellow code gives warning and I really don`t care, the button is in place and works...call me ignorant or whatever but seriously from my point of view the point of coding is not coding itself but designing something that helps you make money. Which is why is true as you said I have not read the entire manual (actually I read it as I was coding) which is why I'm quite sure I've missed a lot of stuff however I got everything I need. Amibroker is such a great software like no other probably.

//roll buttons functionality------------------
chwidth = Status( "pxchartwidth" );
chheight = Status( "pxchartheight" );


GuiButton( "-1", 1, Nz( chwidth + 5 / chwidth*chwidth, 0 ), chheight - 10, 20, 20, 1 );

PS: I`m not interested to fix the above at all :)))

1 Like

Btw, Im afraid to read the manual because I might end up making pancakes with Amibroker and money is enough, Ill buy pancakes :wink:

1 Like

Nothing to apologize for. Forum is exactly for the purpose of learning something new :slight_smile:

2 Likes

@Paul but the "Division by zero" Warning, that you see:

Przechwytywanie

... is really not that difficult to get rid of in the proper way :wink: :

1 Like

The error appears because of division by zero as warning says (Status( "pxchartwidth" ) becomes zero on verify syntax) .

So for example make chwidth variable minimum 1 pixel. Warning will disappear.

chwidth = Max(1, Status( "pxchartwidth" ) );
_TRACEF( "chwidth : %g", chwidth );

BTW,

x = 5 / chwidth*chwidth

gives same result as using just

x = 5

No programming but simple math.

//roll buttons functionality------------------
chwidth = Status( "pxchartwidth" );
chheight = Status( "pxchartheight" );

GuiButton( "-1", 1, chwidth + 5 , chheight - 10, 20, 20, 1 );

No warning too.

5 Likes

This is very useful. I think it is better fit for the manual or the knowledge base.