Skip to content

Language Reference ‐ Identifiers

Andreas AFENTAKIS edited this page Oct 20, 2025 · 9 revisions

Language Reference - Identifiers


Naming Conventions & Rules

Identifiers are names used within FBasic to uniquely denote program elements such as statements, variables, arrays, collections, and defined functions. This section outlines the specific rules governing the construction and interpretation of these names by the interpreter.

General Rules

All identifiers in FBasic must adhere to the following basic rules:

  • They must begin with a letter (A-Z or a-z).
  • They must be composed exclusively of alphabetic characters (letters) and digits (0-9).
  • No other characters are permitted, including spaces, underscores (_), hyphens (-), or special symbols.

Statement Names

Statement names refer to the keywords that define an action or control flow (e.g., PRINT, PUSH, GOTO).

Rule Specification
Allowed Characters Letters and Digits. Must start with a letter.
Word Structure Must be a single, contiguous word (no spaces).
Case Sensitivity Case-Insensitive. The interpreter treats PRINT, print, and Print as the same statement.

Variable, Array, and Collection Names

These names are used for storing and referencing data. They represent user-defined entities.

Rule Specification
Allowed Characters Letters and Digits. Must start with a letter.
Word Structure Must be a single word.
Case Sensitivity Case-Sensitive. The names MyVar and myvar are treated as two distinct, separate identifiers.

Function Names

Function names follow the same naming conventions and case sensitivity rules as variables, arrays, and collections.

Rule Specification
Allowed Characters Letters and Digits. Must start with a letter.
Word Structure Must be a single word.
Case Sensitivity Case-Sensitive. For example, stackcnt() and StackCnt() would refer to different functions if both were defined.

Examples

The table below illustrates valid and invalid identifiers based on the rules for case-sensitive elements (Variables/Functions).

Identifier Valid? Reason / Status
Total1 Valid Starts with a letter, contains only letters and digits.
CustName Valid Contains only letters.
1stVar Invalid Cannot start with a digit.
Array_X Invalid Contains an illegal character (underscore _).
POPTEMP Valid Valid format, but if it clashes with a statement name, a conflict may arise depending on context.
PopTemp Valid If poptemp is a variable, PopTemp is a different variable due to case-sensitivity.
Final Price Invalid Contains a space (must be one word).

How to use

Once an entity (Variable, Collection, or Array) is declared or created in FBasic, it can be referenced to either read its current value or set/update its value. This section details the syntax used for these read and write (assign) operations. The fundamental syntax for manipulating the value of a non-statement entity is through the assignment statement, usually involving the LET keyword (or implicit assignment).

Setting a Value (Assign Operation)

The syntax to store a new value into an entity is:

[LET] entityName = valueOrExpression
Element Description
[LET] The optional assignment keyword.
entityName The identifier of the Variable, Collection, or Array element being set.
= The assignment operator.
valueOrExpression A literal value, another entity's name, or the result of a mathematical or string expression.

Note: The implicit assignment is supported but its a nice practice to avoid it and specify the LET statement

Reading a Value (Read Operation)

To retrieve a value, the entity's identifier is used as part of an expression:

PRINT entityName
LET anotherVar = entityName

Variables

A simple variable holds a single value (numeric or string) and is referenced solely by its unique identifier.

Operation Syntax Example
Set Value LET variableName = value TotalSales = 1500.25
Set Expression expression LET Margin = TotalSales * 0.1
Get Value PRINT variableName PRINT TotalSales

Collections

In FBASIC, collections are fundamental data structures used to manage lists of values and result sets from data sources. While traditional single variables hold one value, collections allow a program to store and iterate over multiple related items efficiently. The two primary collection types referenced in the language are Static (or SDATA) and Dynamic (Fetchable). For more information see the manual page about collections

Arrays

Based on your notes, here is the consolidated and enriched text detailing the foundation and referencing of arrays in FAST.FBasic:

Arrays are a core, 1-based feature of the FAST.FBasic interpreter, where the first element is always at index one (1). Though built-in, they are inert until an external Library (like FBasic2DArrays) initializes and defines their behavior. Internally, the interpreter models arrays as 2D Jagged Arrays (an array of arrays), where the first index acts as the Row (Y-Axis) and the second as the Column (X-Axis). While the primary index is strictly numeric, the secondary (column) index can be accessed either numerically or by a ColumnName (a mnemonic name specified by the array's creator, which might be a Library or a C# host program). Referencing elements is achieved through the standard Parentheses () notation (e.g., array(index)) or the specialized Square Bracket [] notation (e.g., [arr.column(index)]), with the built-in function UBOUND(arrayName) providing the total Row count (length).

Square Bracket Reference [] (Advanced Access)

The Square Bracket Reference provides a specialized syntax for accessing complex data structures, specifically columns within collections (tables) and arrays. Brackets may be present or omitted, depending on the context.

Syntax Applies to Description
[col.Item] Static Collections (also known as SDIM) References the value of the current item in the static collection. The keyword Item can be in any case
[col.column] Collections References the value of a column in the collection. column can be a column name.
[arr.column(index)] Arrays References the value of a specific column of an array at the specified index. This combines column naming with array indexing. The column can be a Column Name or a Number. The index can be a variable or a number

Arrays hold multiple values of the same type, accessed using a numeric index enclosed in parentheses (). Array indexes typically start at 1 (one). This is the standard BASIC array access method.

Entity Operation Syntax Description Example
Collections Assign N/A To assign value in a collection it is not applicable directly. The to collection's item
Get [collection.entity] Read the value for entity or column entity from collection collection print [C1.name]
Static Collection Assign SSET collection index value A static collection is a form of general collections, but using the build-in library for collections, the SSET statment is performing the assignment. Attention to the syntax, does not use comma as argument separator. SSET C1 1 "XXX"
Get [collection.Item] Read the value from static collection collection print [months.Item]
Array Assign [array,index2(index1)] Assign a value to 2D array having index1 (number or name) and index as second dimension index (number or variable. Attension to the sequence of the indexes first the 2nd the in parenthesis the 1st. LET [A1,1(2)]=1234.34 or LET[A1,Col3(index)="XX"
Get [array,index2(index1)] Same syntax of Assign print [arr2,Name(selectedRow)]

//

Clone this wiki locally