Compiler options: As well as Runtime options …a statement diagram: Separate statements with new line or colon sign (:).comment fragment: To prefix with REM or an apostrophe sign.typename: Primitive data type nameschar: Type declaration charactersarray fragment: Multiple optional dimensions, optionalstart lower bound, end upper bound.
lowercase characters indicate information to supply: end, expression, start, variable, …
Basic statement diagrams start and end with double vertical bars,
Loops indicate a possible repetition, an optional separator may be present,
Rectangles denote subsequent diagram fragments,
Diagram fragments extremities exhibit single vertical bars.
[opt1|opt2|opt3] Items inside brackets are optional. Alternatives are indicated with a vertical bar,
case[[sep]…] An ellipsis indicates a possible repetition. An optional separator may be specified,
{choice1|choice2} Items inside curly braces are mandatory. Alternatives are indicated with a vertical bar.
Examples
A statement diagram: Let, New and Set are Basic keywords, expression, object and variable are arguments Let or Set are optional default statements. New creates UNO objects or ClassModule objects.
Testing conditions: Do, If, Select Case, While statements
If … Then …Else statement: …
Select Case … End Select statement: …
Iterating: For statement
For … = … To … Next statement: …
statements: Separate statements with new line or colon sign (:).For Each … In … Next statement: …
Interrupting Flow of Control: Exit …
Procedures: Subs, Functions & Properties
Calling routines: Call statement
…
Declaring routines: Function, Sub & Property statements
Sub statement: As Basic libraries remain in memory, Global and Public scopes are equivalent.
Note: Sub, Function or Property statements are similar methods, without distinction. They receive parameters by reference, allowing them to be modified. LibreOffice Basic compiler accepts their respective syntax to be used interchangeably.
Function statement: As Basic libraries remain in memory, Global and Public scopes are equivalent.Property Get statement: As Basic libraries remain in memory, Global and Public scopes are equivalent.Property Set statement: As Basic libraries remain in memory, Global and Public scopes are equivalent.
Note: Property setters often use a single argument. Multiple arguments are equally accepted.
Arguments in routines
argument fragment: Syntax parameters in Function, Property or Sub statements
Tip:
Extended types such as Type statement structures, UNO services, or ClassModule objects are valid typenames.
Return values
Interrupting flow: Exit …, GoSub/GoTo, On … GoSub/GoTo statements
On … GoTo - On … GoSub statements
File System
Folders
MkDir statementRmDir statement
Opening & Closing files
Open statementaccess fragmentlocking fragmentClose # statement: Closing a set of files or all files.Reset statement: Writing buffers to disk and Closing files.Seek # statement: Setting file offset.
Binary/Random files
Get # statement: Reading Binary or Random files.Put # statement: Writing Binary or Random files.
Sequential files
Input # statement: Reading from fileLine Input # statement: Reading from filePrint [#] statement: Output to file or to screen with Ok and optional Cancel button. Write # statement: Output to file
User-Defined Data Types & Classes
Objects: Type, With statements, New keyword
Type Statement: Separate datafields with new line … Scoping with Global, Private or Public has no effect !
Class modules: constructor, destructor
Properties, Methods, Events
Error Processing
LibreOffice Basic: Erl, Err, Error, On … Error, Resume statements
On Error …
Resume statement
Calc: CvErr, IsError functions
VBA: Err object
Exception Class - e.Number=Err, e.Description=Error$, e.Source