Organizing code

Blitz3D Forums/Blitz3D Programming/Organizing code

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

HRC_SPIDER

Blitz evaluates all conditions in an IF statement and doesn't "early out" like most languages do. So if you have 8 checks in long IF connected with " And " operands, Blitz is going to evaluate all 8 conditions, even if the first one turns out to be FALSE.

So if you have something expensive as part of a string of conditions, break it out and put it underneath in another level of indentation.

It's also fun because you can't do this sort of thing:

if( Player <> Null And Player\Score > 0 )

...because if Player turns out to be Null, Blitz will still attempt to evaluate the right side of the "And" and crash.

You have to do:

If( Player <> Null )
If( Player\Score > 0 )