Revision history for KeyPgDim


Revision [22242]

Last edited on 2018-02-15 14:30:26 by fxm [Formatting]
Additions:
Array values are given in comma-delimited values enclosed by curly brackets, and UDT values are given in comma delimited values enclosed by parenthesis. These methods of initializing variables can be nested within one another for complex assignments. Nesting allows for arrays of any dimension to be initialized.
Deletions:
Array values are given in comma-delimited values enclosed by curly brackets, and UDT values are given in comma delimited values enclosed by parenthesis. These methods of initializing variables can be nested within one another for complex assignments. Nesting allows for arrays of any dimension to be initialized.


Revision [21285]

Edited on 2016-04-01 07:56:43 by fxm [Added link to BYREF (variables)]
Additions:
- ##[[KeyPgByrefVariables|Byref (variables)]]##


Revision [20905]

Edited on 2016-03-12 16:57:11 by fxm [Formatting]

No Differences

Revision [20201]

Edited on 2016-02-10 15:59:09 by DkLwikki [Update link format]
Additions:
##**Dim** [[[KeyPgShared|Shared]]] //name1// As [[DataType|DataType]] [, //name2// As [[DataType|DataType]], ...]##
##**Dim** [[[KeyPgShared|Shared]]] As [[DataType|DataType]] //name1// [, //name2//, ...]##
##**Dim** //name// ( [//lbound// [[KeyPgTo|To]]] //ubound// [, ...] ) As [[DataType|DataType]]##
##**Dim** //name// ( [[KeyPgAny|Any]] [, [[KeyPgAny|Any]]...] ) As [[DataType|DataType]]##
##**Dim** //name// ( ) As [[DataType|DataType]]##
##**Dim** //scalar_symbol// As [[DataType|DataType]] = //expression// | [[KeyPgAny|Any]]##
##**Dim** //array_symbol// (//arraybounds//) As [[DataType|DataType]] = { //expression// [, ...] } | [[KeyPgAny|Any]]##
##**Dim** //udt_symbol// As [[DataType|DataType]] = ( //expression// [, ...] ) | [[KeyPgAny|Any]]##
Variables must be declared before they can be used in the //[[CompilerOptlang|-lang fb]]// dialect or when using ##[[KeyPgOptionexplicit|Option Explicit]]## in the other dialects. Only in the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects variables may be used without first declaring them, in such a case they are called implicit variables.
Depending on where and how a variable or array is declared can change how it is allocated in memory. See //[[ProPgStorageClasses|Storage Classes]]//.
In the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, even if the variable is declared explicitly, it will be given a default data type if the data type is not explicitly given either by name or by type suffix. The default data type is ##[[KeyPgSingle|Single]]## in the //[[CompilerOptlang|-lang qb]]// dialect and ##[[KeyPgInteger|Integer]]## in the //[[CompilerOptlang|-lang fblite]]// dialect. The default data type can be changed throughout a source listing by use of the ##**Def""###""**## statements. (for example, ##[[KeyPgDefint|DefInt]]##, ##[[KeyPgDefstr|DefStr]]##, ##[[KeyPgDefsng|DefSng]]##)
As with most BASIC dialects, ""FreeBASIC"" supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. ##//ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase|Option Base]]## is used.
For more information on arrays see [[ProPgArrays|Arrays Overview]].
If the values used with ##**Dim**## to declare the dimensions of an array are all constants, the array will be created ##[[KeyPgOptionstatic|Static]]## (unless ##[[KeyPgOptiondynamic|Option Dynamic]]## is specified), while using one or more variables to declare the dimensions of an array makes it variable length, even if ##[[KeyPgOptionstatic|Option Static]]## is in effect.
Arrays can be declared as variable length in several ways: Using ##**Dim**## with an empty set of indexes (##**Dim** x()##), using ##**Dim**## with indexes that are variables or using the keyword ##[[KeyPgRedim|Redim]]##, or using ##[[KeyPgAny|Any]]## in place of the array bounds, or declaring it past the metacommand ##[[KeyPgMetaDynamic|$Dynamic]]##. Variable length arrays can't use initializers.
Arrays declared with ##**Dim**## having constant indexes and not preceeded by ##[[KeyPgOptiondynamic|Option Dynamic]]## are fixed length (not resizable at runtime) and can use initializers.
The upper bound can be an ellipsis (##[[KeyPgDots|...]]##, 3 dots). This will cause to upper bound to be set automatically based on the number of elements found in the initializer. When ellipsis is used in this manner, an initializer must be used, and it may not be ##**Any**##. See the [[KeyPgDots|Ellipsis]] page for a short example.
See also //[[ProPgFixLenArrays|Fixed-Length Arrays]]// and //[[ProPgVarLenArrays|Variable-Length Arrays]]//.
Arrays, variables, strings, and user defined types (UDTs) are initialized to zero (or ##[[KeyPgFalse|False]]## for ##[[KeyPgBoolean|Boolean]]##) or null strings by default when they are created.
In the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, the data type of a variable may be indicated with a type suffix ( ##$## ##%## ##""#""## ##!## ##&## ).
- In the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, variables have procedure scope if the variable is defined inside a procedure, and for the entire module if the variable is defined with ##**Dim Shared**##.
- In the //[[CompilerOptlang|-lang qb]]// dialect, variables cannot be initialised. In the //[[CompilerOptlang|-lang fblite]]// dialect, the variable is initialised with a default value at the start of the procedure/module, and assigned its initial value if/when the ##**Dim**## statement is executed at runtime.
- In the //[[CompilerOptlang|-lang fb]]// and //[[CompilerOptlang|-lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext|For..Next]]##, ##[[KeyPgWhilewend|While..Wend]]##, ##[[KeyPgDoloop|Do..Loop]]##, ##[[KeyPgIfthen|If..Then]]##, ##[[KeyPgSelectcase|Select..End Select]]##, ##[[KeyPgWith|With..End With]]##, ##[[KeyPgScope|Scope..End Scope]]##) have local working [[ProPgVariableScope|scopes]], and are visible only within these blocks.
- In the //[[CompilerOptlang|-lang fb]]// dialect, ##**Option**## statements (e.g. ##[[KeyPgOptionbase|Option Base]]##, ##[[KeyPgOptiondynamic|Option Dynamic]]##), metacommands(e.g. ##[[KeyPgMetaStatic|$Static]]##) and ##**Def""###""**## statements (e.g. ##[[KeyPgDefint|DefInt]]##) are not allowed.
- ##[[KeyPgVar|Var]]##
- ##[[KeyPgCommon|Common]]##
- ##[[KeyPgExtern|Extern]]##
- ##[[KeyPgRedim|Redim]]##
- ##[[KeyPgPreserve|Preserve]]##
- ##[[KeyPgShared|Shared]]##
- ##[[KeyPgStatic|Static]]##
- ##[[KeyPgErase|Erase]]##
- ##[[KeyPgLbound|LBound]]##
- ##[[KeyPgUbound|UBound]]##
- ##[[KeyPgDots|... (Ellipsis)]]##
- ##[[KeyPgAny|Any]]##
Deletions:
##**Dim** [[[KeyPgShared Shared]]] //name1// As [[DataType DataType]] [, //name2// As [[DataType DataType]], ...]##
##**Dim** [[[KeyPgShared Shared]]] As [[DataType DataType]] //name1// [, //name2//, ...]##
##**Dim** //name// ( [//lbound// [[KeyPgTo To]]] //ubound// [, ...] ) As [[DataType DataType]]##
##**Dim** //name// ( [[KeyPgAny Any]] [, [[KeyPgAny Any]]...] ) As [[DataType DataType]]##
##**Dim** //name// ( ) As [[DataType DataType]]##
##**Dim** //scalar_symbol// As [[DataType DataType]] = //expression// | [[KeyPgAny Any]]##
##**Dim** //array_symbol// (//arraybounds//) As [[DataType DataType]] = { //expression// [, ...] } | [[KeyPgAny Any]]##
##**Dim** //udt_symbol// As [[DataType DataType]] = ( //expression// [, ...] ) | [[KeyPgAny Any]]##
Variables must be declared before they can be used in the //[[CompilerOptlang -lang fb]]// dialect or when using ##[[KeyPgOptionexplicit Option Explicit]]## in the other dialects. Only in the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects variables may be used without first declaring them, in such a case they are called implicit variables.
Depending on where and how a variable or array is declared can change how it is allocated in memory. See //[[ProPgStorageClasses Storage Classes]]//.
In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, even if the variable is declared explicitly, it will be given a default data type if the data type is not explicitly given either by name or by type suffix. The default data type is ##[[KeyPgSingle Single]]## in the //[[CompilerOptlang -lang qb]]// dialect and ##[[KeyPgInteger Integer]]## in the //[[CompilerOptlang -lang fblite]]// dialect. The default data type can be changed throughout a source listing by use of the ##**Def""###""**## statements. (for example, ##[[KeyPgDefint DefInt]]##, ##[[KeyPgDefstr DefStr]]##, ##[[KeyPgDefsng DefSng]]##)
As with most BASIC dialects, ""FreeBASIC"" supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. ##//ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase Option Base]]## is used.
For more information on arrays see [[ProPgArrays Arrays Overview]].
If the values used with ##**Dim**## to declare the dimensions of an array are all constants, the array will be created ##[[KeyPgOptionstatic Static]]## (unless ##[[KeyPgOptiondynamic Option Dynamic]]## is specified), while using one or more variables to declare the dimensions of an array makes it variable length, even if ##[[KeyPgOptionstatic Option Static]]## is in effect.
Arrays can be declared as variable length in several ways: Using ##**Dim**## with an empty set of indexes (##**Dim** x()##), using ##**Dim**## with indexes that are variables or using the keyword ##[[KeyPgRedim Redim]]##, or using ##[[KeyPgAny Any]]## in place of the array bounds, or declaring it past the metacommand ##[[KeyPgMetaDynamic $Dynamic]]##. Variable length arrays can't use initializers.
Arrays declared with ##**Dim**## having constant indexes and not preceeded by ##[[KeyPgOptiondynamic Option Dynamic]]## are fixed length (not resizable at runtime) and can use initializers.
The upper bound can be an ellipsis (##[[KeyPgDots ...]]##, 3 dots). This will cause to upper bound to be set automatically based on the number of elements found in the initializer. When ellipsis is used in this manner, an initializer must be used, and it may not be ##**Any**##. See the [[KeyPgDots Ellipsis]] page for a short example.
See also //[[ProPgFixLenArrays Fixed-Length Arrays]]// and //[[ProPgVarLenArrays Variable-Length Arrays]]//.
Arrays, variables, strings, and user defined types (UDTs) are initialized to zero (or ##[[KeyPgFalse False]]## for ##[[KeyPgBoolean Boolean]]##) or null strings by default when they are created.
In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, the data type of a variable may be indicated with a type suffix ( ##$## ##%## ##""#""## ##!## ##&## ).
- In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, variables have procedure scope if the variable is defined inside a procedure, and for the entire module if the variable is defined with ##**Dim Shared**##.
- In the //[[CompilerOptlang -lang qb]]// dialect, variables cannot be initialised. In the //[[CompilerOptlang -lang fblite]]// dialect, the variable is initialised with a default value at the start of the procedure/module, and assigned its initial value if/when the ##**Dim**## statement is executed at runtime.
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgSelectcase Select..End Select]]##, ##[[KeyPgWith With..End With]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.
- In the //[[CompilerOptlang -lang fb]]// dialect, ##**Option**## statements (e.g. ##[[KeyPgOptionbase Option Base]]##, ##[[KeyPgOptiondynamic Option Dynamic]]##), metacommands(e.g. ##[[KeyPgMetaStatic $Static]]##) and ##**Def""###""**## statements (e.g. ##[[KeyPgDefint DefInt]]##) are not allowed.
- ##[[KeyPgVar Var]]##
- ##[[KeyPgCommon Common]]##
- ##[[KeyPgExtern Extern]]##
- ##[[KeyPgRedim Redim]]##
- ##[[KeyPgPreserve Preserve]]##
- ##[[KeyPgShared Shared]]##
- ##[[KeyPgStatic Static]]##
- ##[[KeyPgErase Erase]]##
- ##[[KeyPgLbound LBound]]##
- ##[[KeyPgUbound UBound]]##
- ##[[KeyPgDots ... (Ellipsis)]]##
- ##[[KeyPgAny Any]]##


Revision [17804]

Edited on 2015-09-19 07:08:44 by FxMwikki [Booleans are initialized to False by default when they are created]
Additions:
Arrays, variables, strings, and user defined types (UDTs) are initialized to zero (or ##[[KeyPgFalse False]]## for ##[[KeyPgBoolean Boolean]]##) or null strings by default when they are created.
Deletions:
Arrays, variables, strings, and user defined types (UDTs) are initialized to zero or null strings by default when they are created.


Revision [17704]

Edited on 2015-06-28 15:53:00 by FxMwikki [With..End With is also a compound block statement]
Additions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgSelectcase Select..End Select]]##, ##[[KeyPgWith With..End With]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.
Deletions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgSelectcase Select..End Select]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.


Revision [17665]

Edited on 2015-06-11 13:04:17 by FxMwikki [Select..End Select is also a compound block statement]
Additions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgSelectcase Select..End Select]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.
Deletions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.


Revision [17605]

Edited on 2015-04-19 04:13:31 by FxMwikki [Wording]
Additions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgScope Scope..End Scope]]##) have local working [[ProPgVariableScope scopes]], and are visible only within these blocks.
Deletions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgScope Scope..End Scope]]##) have local [[ProPgVariableScope scopes]], and are visible only within these blocks.


Revision [17288]

Edited on 2014-09-23 11:29:34 by CountingPine [Initialisation in qb/fblite dialects: disallowed in qb, works differently in fblite.]
Additions:
- In the //[[CompilerOptlang -lang qb]]// dialect, variables cannot be initialised. In the //[[CompilerOptlang -lang fblite]]// dialect, the variable is initialised with a default value at the start of the procedure/module, and assigned its initial value if/when the ##**Dim**## statement is executed at runtime.


Revision [17037]

Edited on 2014-04-26 10:23:05 by DkLwikki [Reformat and document array(any, any, ...)]
Additions:
##**Dim** [[[KeyPgShared Shared]]] //name1// As [[DataType DataType]] [, //name2// As [[DataType DataType]], ...]##
//or//
##**Dim** [[[KeyPgShared Shared]]] As [[DataType DataType]] //name1// [, //name2//, ...]##
Arrays:
##**Dim** //name// ( [//lbound// [[KeyPgTo To]]] //ubound// [, ...] ) As [[DataType DataType]]##
##**Dim** //name// ( [[KeyPgAny Any]] [, [[KeyPgAny Any]]...] ) As [[DataType DataType]]##
##**Dim** //name// ( ) As [[DataType DataType]]##
Initializers:
##**Dim** //scalar_symbol// As [[DataType DataType]] = //expression// | [[KeyPgAny Any]]##
##**Dim** //array_symbol// (//arraybounds//) As [[DataType DataType]] = { //expression// [, ...] } | [[KeyPgAny Any]]##
As with most BASIC dialects, ""FreeBASIC"" supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. ##//ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase Option Base]]## is used.
Arrays can be declared as variable length in several ways: Using ##**Dim**## with an empty set of indexes (##**Dim** x()##), using ##**Dim**## with indexes that are variables or using the keyword ##[[KeyPgRedim Redim]]##, or using ##[[KeyPgAny Any]]## in place of the array bounds, or declaring it past the metacommand ##[[KeyPgMetaDynamic $Dynamic]]##. Variable length arrays can't use initializers.
To avoid the overhead of default variable initialization, the ##**Any**## initializer can be used with ##**Dim**## to tell the compiler to only reserve the place for the variable in memory but not initialize it, so the variable will contain garbage. In this case the programmer should not make assumptions about the initial values.
- ##[[KeyPgAny Any]]##
Deletions:
Declaring a Single Variable:
##**Dim** [[[KeyPgShared Shared]]] //symbolname// [As [[DataType DataType]]] [, ...]##
##**Dim** [[[KeyPgShared Shared]]] As [[DataType DataType]] //symbolname// [, ...]##
Declaring Arrays:
##**Dim** [[[KeyPgShared Shared]]] //symbolname// ( [//lbound// To] //ubound// [, ...] ) [As [[DataType DataType]]] [,...]##
##**Dim** [[[KeyPgShared Shared]]] As [[DataType DataType]] //symbolname// ( [//lbound// To] //ubound// [, ...] ) [,...]##
Initializing Values:
##**Dim** //scalar_symbol// As [[DataType DataType]]] = //expression// | [[KeyPgAny Any]]##
##**Dim** //array_symbol// ([//lbound// To] //ubound//) [AS [[DataType DataType]]] => { //expression// [, ...] } | [[KeyPgAny Any]]##
{{fbdoc item="section" value="Explicit Variables with Explicit Data Types"}}
In the default dialect //[[CompilerOptlang -lang fb]]//, each variable must be explicitly declared with a desired data type. Type suffixes are not allowed.
As with most BASIC dialects, ""FreeBASIC"" supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. And ##//Ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase Option Base]]## is used.
Arrays can be declared as variable length in several ways: Using ##**Dim**## with an empty set of indexes (##**Dim** x()##), using ##**Dim**## with indexes that are variables or using the keyword ##[[KeyPgRedim Redim]]##, or declaring it past the metacommand ##[[KeyPgMetaDynamic $Dynamic]]##. Variable length arrays can't use initializers.
To avoid the overhead of initializing the variables the ##**Any**## initializer can be used with ##**Dim**## to tell the compiler to only reserve the place for the variable in memory but don't initialize it, so the variable will contain garbage. In this case the programmer should not make assumptions about the initial values.


Revision [16294]

Edited on 2012-08-17 10:39:00 by FxMwikki [Visibility of variables declared inside an If..Then block]
Additions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgIfthen If..Then]]##, ##[[KeyPgScope Scope..End Scope]]##) have local [[ProPgVariableScope scopes]], and are visible only within these blocks.
Deletions:
- In the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang deprecated]]// dialects, variables defined inside compound block statements (##[[KeyPgFornext For..Next]]##, ##[[KeyPgWhilewend While..Wend]]##, ##[[KeyPgDoloop Do..Loop]]##, ##[[KeyPgScope Scope..End Scope]]##) have local [[ProPgVariableScope scopes]], and are visible only within these blocks.


Revision [16072]

Edited on 2012-02-04 09:20:41 by FxMwikki [Initializing UDT containing data-field initializer or string is not valid]
Additions:
Note: Initializing UDT's with strings is not supported at this time. Initializing UDT containing data-field initializer or string is not valid.
Deletions:
Note: Initializing UDT's with strings is not supported at this time. Initializing UDT containing data-field initializer is not valid.


Revision [16071]

Edited on 2012-02-04 09:02:53 by FxMwikki [Initializing UDT containing data-field initializer is not valid]
Additions:
Fixed-length arrays, variables, zstrings and UDTs may be given a value at the time of their declaration by following the variable declaration with an initializer. Note the difference between initializing different types. Arrays, variables and UDTs are initialized as they would in a normal assignment, using an equal ( ##=## ) sign. The ##=>## sign can be used, allowing to avoid the declaration resembling an expression when declaring fixed length strings.
Note: Initializing UDT's with strings is not supported at this time. Initializing UDT containing data-field initializer is not valid.
Deletions:
Fixed-length arrays, variables, zstrings and UDTs may be given a value at the time of their declaration by following the variable declaration with an initializer. Note the difference between initializing different types. Arrays, variables and UDTs are initialized as they would in a normal assignment, using an equal ( ##=## ) sign. The ##=>## sign can be used with fixed length strings to avoid the declaration resembling an expression.
Note: Initializing UDT's with strings is not supported at this time.


Revision [15867]

Edited on 2012-01-26 19:13:00 by CountingPine ["FreeBasic" -> "FreeBASIC" in example]
Additions:
s2 = "Hello World from FreeBASIC!"
Deletions:
s2 = "Hello World from FreeBasic!"


Revision [15735]

Edited on 2012-01-19 08:29:05 by FxMwikki [Reword storage order definition for array]
Additions:
Multidimensional arrays can be declared as well, and are stored in this definite order: values differing only in the last index are contiguous (row-major order).
The maximum number of dimensions of a multidimensional array is 8.
Deletions:
Multidimensional arrays can be declared as well, and are stored in this definite order: values differing only in the last index are contiguous (row-major order). The maximum number of dimensions of a multidimensional array is 8.


Revision [15734]

Edited on 2012-01-19 07:49:30 by FxMwikki [Reword storage order definition]
Additions:
Multidimensional arrays can be declared as well, and are stored in this definite order: values differing only in the last index are contiguous (row-major order). The maximum number of dimensions of a multidimensional array is 8.
- Multidimensional arrays are stored in this definite order: values differing only in the last index are contiguous (row-major order), they were stored in opposite order in QB by default: values differing only in the first index were contiguous (column-major order).
Deletions:
Multidimensional arrays can be declared as well. and are stored in column-major order: values with the same first index are contiguous. (This is different from QB's default). The maximum number of dimensions of a multidimensional array is 8.
- Multidimensional arrays are stored in column-major order in ""FreeBASIC"", they were stored in row-major order in QB by default. Column major order: values with the same first index are contiguous. Row-major order: values with the same last index are contiguous.


Revision [15662]

Edited on 2012-01-15 11:23:23 by MySoft [ok, qb was actually row order and fb column.... (so now it's correct)]
Additions:
Multidimensional arrays can be declared as well. and are stored in column-major order: values with the same first index are contiguous. (This is different from QB's default). The maximum number of dimensions of a multidimensional array is 8.
- Multidimensional arrays are stored in column-major order in ""FreeBASIC"", they were stored in row-major order in QB by default. Column major order: values with the same first index are contiguous. Row-major order: values with the same last index are contiguous.
Deletions:
Multidimensional arrays can be declared as well. and are stored in row-major order: values with the same first index are contiguous. (This is different from QB's default). The maximum number of dimensions of a multidimensional array is 8.
- Multidimensional arrays are stored in row-major order in ""FreeBASIC"", they were stored in column-major order in QB by default. Row major order: values with the same first index are contiguous. Column-major order: values with the same last index are contiguous.


Revision [15661]

Edited on 2012-01-15 11:15:13 by MySoft [swap row-major / column-major definition...]
Additions:
Multidimensional arrays can be declared as well. and are stored in row-major order: values with the same first index are contiguous. (This is different from QB's default). The maximum number of dimensions of a multidimensional array is 8.
Deletions:
Multidimensional arrays can be declared as well. and are stored in row-major order: values with the same last index are contiguous. (This is different from QB's default). The maximum number of dimensions of a multidimensional array is 8.


Revision [15660]

Edited on 2012-01-15 11:10:29 by MySoft [swap row-major / column-major definition...]
Additions:
- Multidimensional arrays are stored in row-major order in ""FreeBASIC"", they were stored in column-major order in QB by default. Row major order: values with the same first index are contiguous. Column-major order: values with the same last index are contiguous.
Deletions:
- Multidimensional arrays are stored in row-major order in ""FreeBASIC"", they were stored in column-major order in QB by default. Row major order: values with the same last index are contiguous. Column-major order: values with the same first index are contiguous.


Revision [14764]

Edited on 2010-08-20 06:30:12 by GaLeon [Added periods in differences from QB section]
Additions:
- Variable Initializers are new to ""FreeBASIC"".
- The alternate syntax ##Dim As DataType //symbolname//, [...]## is new to ""FreeBASIC"".
- The ellipsis form for upper bounds is new to ""FreeBASIC"".
Deletions:
- Variable Initializers are new to ""FreeBASIC""
- The alternate syntax ##Dim As DataType //symbolname//, [...]## is new to ""FreeBASIC""
- The ellipsis form for upper bounds is new to ""FreeBASIC""


Revision [13874]

Edited on 2008-11-09 10:01:37 by CountingPine [Minor edits, mainly formatting]
Additions:
As with most BASIC dialects, ""FreeBASIC"" supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. And ##//Ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase Option Base]]## is used.
The upper bound can be an ellipsis (##[[KeyPgDots ...]]##, 3 dots). This will cause to upper bound to be set automatically based on the number of elements found in the initializer. When ellipsis is used in this manner, an initializer must be used, and it may not be ##**Any**##. See the [[KeyPgDots Ellipsis]] page for a short example.
For module-level, fixed-length, or global variables, initialized values must be constant expressions. ""FreeBASIC"" will report a compile-time error if otherwise.
In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, the data type of a variable may be indicated with a type suffix ( ##$## ##%## ##""#""## ##!## ##&## ).
- Variable Initializers are new to ""FreeBASIC""
- The alternate syntax ##Dim As DataType //symbolname//, [...]## is new to ""FreeBASIC""
- Multidimensional arrays are stored in row-major order in ""FreeBASIC"", they were stored in column-major order in QB by default. Row major order: values with the same last index are contiguous. Column-major order: values with the same first index are contiguous.
- Variable length arrays up to 2 ""GiB"" in size are possible in ""FreeBASIC"". In QB, ##$STATIC## arrays were limited to 64 ""KiB"" , or to the DOS memory available (several 100 ""KiB"" at best) if made ##$DYNAMIC## and ///AH// was used.
- The ellipsis form for upper bounds is new to ""FreeBASIC""
- ##[[KeyPgDots ... (Ellipsis)]]##
Deletions:
As with most BASIC dialects, FreeBASIC supports arrays with indexes ranging from a lower bound to an upper bound. In the syntaxes shown, ##//lbound//## refers to the lower bound, or the smallest index. And ##//Ubound//## refers to the upper bound, or the largest index. If a lower bound is not specified, it is assumed to be zero by default, unless ##[[KeyPgOptionbase Option Base]]## is used.
The upper bound can be an ellipsis (**...**, 3 dots). This will cause to upper bound to be set automatically based on the number of elements found in the initializer. When ellipsis is used in this manner, an initializer must be used, and it may not be ##**Any**##. See the [[KeyPgDots Ellipsis]] page for a short example.
For module-level, fixed-length, or global variables, initialized values must be constant expressions. FreeBASIC will report a compile-time error if otherwise.
In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, the data type of a variable may be indicated with a type suffix ( $ % # ! & ).
- Variable Initializers are new to FreeBASIC
- The alternate syntax ##Dim As DataType //symbolname//, [...]## is new to FreeBASIC
- Multidimensional arrays are stored in row-major order in FreeBASIC, they were stored in column-major order in QB by default. Row major order: values with the same last index are contiguous. Column-major order: values with the same first index are contiguous.
- Variable length arrays up to 2 ""GiB"" in size are possible in FreeBASIC. In QB, $Static arrays were limited to 64 ""KiB"" , or to the DOS memory available (several 100 ""KiB"" at best) if made $Dynamic and ///AH// was used.
- The ellipsis form for upper bounds is new to FreeBASIC


Revision [13873]

Edited on 2008-11-09 08:54:32 by YetiFoot [Ellipsis form for upper bounds]
Additions:
The upper bound can be an ellipsis (**...**, 3 dots). This will cause to upper bound to be set automatically based on the number of elements found in the initializer. When ellipsis is used in this manner, an initializer must be used, and it may not be ##**Any**##. See the [[KeyPgDots Ellipsis]] page for a short example.
- The ellipsis form for upper bounds is new to FreeBASIC


Revision [13781]

Edited on 2008-10-12 06:05:44 by DoS386 [word swap, minor]
Additions:
Variables must be declared before they can be used in the //[[CompilerOptlang -lang fb]]// dialect or when using ##[[KeyPgOptionexplicit Option Explicit]]## in the other dialects. Only in the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects variables may be used without first declaring them, in such a case they are called implicit variables.
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_1.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_2.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_3.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_4.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_5.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_7.bas"}}%%(freebasic)
- Variable length arrays up to 2 ""GiB"" in size are possible in FreeBASIC. In QB, $Static arrays were limited to 64 ""KiB"" , or to the DOS memory available (several 100 ""KiB"" at best) if made $Dynamic and ///AH// was used.
Deletions:
Variables must be declared before they can be used in the //[[CompilerOptlang -lang fb]]// dialect or when using ##[[KeyPgOptionexplicit Option Explicit]]## in the other dialects. Only in the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects may variables be used without first declaring them. Variables that are used without first declaring them are called implicit variables.
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_1.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_2.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_3.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_4.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_5.bas"}}%%(freebasic)
{{fbdoc item="filename" value="examples/manual/check/KeyPgDim_7.bas"}}%%(freebasic)
- Variable length arrays up to 2GB in size are possible in FreeBASIC. In QB, $Static arrays were limited to 64KB and to the DOS memory available (several 100 KB at best) if made $Dynamic and ///AH// was used.


Revision [13596]

Edited on 2008-07-21 15:45:48 by JeffMarshall [added #lang or $lang to example]
Additions:
'$lang: "qb"
DefInt I-N
Dim I, J, X, Y, T$, D As Double
'$lang: "qb"
Deletions:
DEFINT I-N
DIM I, J, X, Y, T$, D AS DOUBLE


Revision [12907]

The oldest known version of this page was created on 2008-04-13 08:35:19 by JeffMarshall [added #lang or $lang to example]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode