Futurebasic/language/variables

< Futurebasic < language

Variables

In FB, a variable can be thought of as a named container for data. The "container" has a specific size and (usually) a specific address in memory. Also, each variable has a specific type which determines how FB interprets its contents. You can copy data into a variable by putting the variable on the left side of the "=" symbol in a LET statement; or by explicitly modifying the contents at the variable's address (through statements like POKE and BLOCKMOVE). Certain other FB statements and functions (such as SWAP and INC) may also modify a variable when you include the variable as a parameter. In FB, a variable can have any of the following forms:

Variables Involving Fields of "true records"

The fields of a "true record" are defined inside a BEGIN RECORD...END RECORD block. A field's declared data type can be any valid type; if a field is itself declared as another "true record" type, then the field can have "subfields," which are just the fields of that secondary record.

A field can also be declared as an array (of any type). In this case, whenever the field's name is included as part of a variable specification, it must be followed by subscript(s) in parentheses. Thus, in each of the variable descriptions listed below, each field and subfield takes one of the following forms, depending on whether or not it's an array field.

For non-array fields:

field/subfield ::= fieldName[tiSuffix]

For array fields:

field/subfield ::= fieldName[tiSuffix](sub1 [,sub2...])

The type and size of each of the following variables is just the type and size of the last field or subfield specified.

Limitations

There are some limitations on how many variables can be assigned.

  1. Arrays are limited to about 2 gigabytes (each).
  2. Simple variables inside of a local function are limited to 32K (per local function). In FBtoC the limit for local arrays is the same of global arrays (2 gigabytes). (See Why translate to C when I code in BASIC? ).
  3. The .MAIN file of a project often allocates variables outside of local functions that are not global. These are treated as variables for a local function and are limited to 32K. In FBtoC the limit is the same of global arrays (2 gigabytes).
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.