Prev Page Next Page
Programming
Previous Top Next

In B4Script statements, operations and names are case-insensitive.
A program starts with an initial code section at the beginning of the program. All Subs must follow this code section. Execution commences at the first line of the program and ends when AppClose is executed or if the code tries to run off the end of this initial section into the first Sub.

Variable and Sub names must start with a letter and may contain letters, numbers, underscores ( _ ) and sharps ( # ). Variables, except for arrays, do not need to be explicitly declared. Any variables used in the initial (non Sub) section of code are global variables and are accessible from within any Sub. Any variables used for the first time in a Sub that are not global are local to that Sub. A local variable name may not be the same as a global variable name so, because parameter names are local names, if a global name is used as a parameter name in a Sub definition then an error occurs. Global variables can of course be passed as parameters and all parameters are passed as values.

There is a pre-defined global array, Args(), that contains an argument array passed to the script at runtime.

Strings can be either single or double quotes delimited. The opening delimiter is matched with the closing delimiter allowing the use of the other delimiter within a string literal.
var = "a 'string' within a string"
var = 'a "string" within a string'

Literal numbers are accepted in decimal form with an optional decimal point or can be specified in scientific notation.
var = 1.234
var = 123.4E-2

Only multi-line If statements are allowed. That is:
If Something Then
            DoSomething
End If

Single line If statements like this are not supported:
If Something Then DoSomething

Rem is provided for comments but must start a statement on a new line.

The colon statement separator is not supported. Only one statement per line is allowed.

Global variables are always cleared to an empty string at the the start of program execution. Local variables are not guaranteed to be be cleared and so should always be explicitly initialised by the program if this is important.

Select ... End Select structures cannot be directly nested. That is code in a Case may not contain another Select ... End Select although it is permissible to call a Sub that does contain another Select ... End Select structure.

Goto can only be used to jump within a scope or to an outer scope. That is it cannot be used to jump into a For...Next, Do...Loop, If...End If or Select ... End Select structure. It is permissible to jump over or out of such structures but not land within them.

Errors are reported back to the host application and will usually be reported to the user. Most errors are self-explanatory but if the error is "Index was outside the bounds of the array" and it does not seem to be associated with an actual array access statement then an unterminated string is the likely cause.




  
Prev Page Next Page
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)