The syntactic and semantic structure of B4P allow powerful features such as multiple-word naming for variables, functions and tables, as well as other benefits. However, even experienced programmers trip into some pitfalls. This section makes you aware of the most the most common pitfalls.
In regular programming languages, keywords are treated as reserved keywords or variables. In B4P, they are plain text. To use these strings to access variables, do not forget to add [] behind it. No differnece applies if you access a subscript of an array or a structure, e.g. a[10].
In conventional languages, the three key statements inside for loops are separated by semicolons, e.g. for( a = 1; a < 10; a++ ). To make things
even worse, multiple statements inside the three statements are separted by commas.
In B4P, for() is treated like a procedure call where parameters are separated with commas and not with semicolons. This function accepts
code pieces as parameters. Multiple statements inside a parameter are separated with semicolons. Right formulation: for ( a[]=1, a[]<10, a[]++).
If you are comparing things using the = or <> symbols, note that these two comparison operators (but not == and !=) can expect
more than 1 operand. For example, a[] = 2,3,5,7,11 is a legitimate expression to compare a[] with five different prime numbers.
With b[] = 6, the expression a[] = { 1, b[]=5, 6, 7, 8 } is actually resulting { 1, true } because the comparison has hijacke the remaining
parameters in the set. Add parenthese to avoid this, e.g. a[] = { 1, (b[]=5), 6, 7, 8 } which returns {1, false, 6, 7, 8}.
Please see the details on the Memory Effect when referencing table heades with string values as they are normally checked once and the column number will be memorized for future use in order accelerate performance significantly.
Since B4P's unique cababilties of supporting multi-word identifiers for variables, tables and function names, one drawback needs to be covercome: Whenever single statements follows else, then a colon is needed to keep them separated.
You may likely have forgotten a closing parenthesis after the function beginning with table process ... and other functions which expect
a code piece in the last parameter. With the missing closing parameter, B4P tries to include the entire remaining code into that function
parameter.
Action: Go back to that function call and ensure that all closing parentheses are included. Example:
table process selected rows(table, [sine] = sin( [angle] ); // Attention: One parenthesis is missing!
table process selected rows(table, [sine] = sin( [angle] ) ); // This one is OK