Revision history for ProPgFixLenArrays


Revision [22552]

Last edited on 2019-01-13 18:51:05 by JeffMarshall [example updated from repo]
Additions:
Dim e(9, 9, 9, 9) As Integer '' 4-dimensional, 10 * 10 * 10 * 10 elements
Deletions:
Dim e(99, 99, 99, 99) As Integer '' 4-dimensional, 100 * 100 * 100 * 100 elements


Revision [22477]

Edited on 2018-09-03 16:39:53 by JeffMarshall [small fix to compile example]
Additions:
Dim a(1) As Integer '' 1-dimensional, 2 elements (0 and 1)
Dim b(0 To 1) As Integer '' 1-dimensional, 2 elements (0 and 1)
Dim c(5 To 10) As Integer '' 1-dimensional, 5 elements (5, 6, 7, 8, 9 and 10)
Dim d(1 To 2, 1 To 2) As Integer '' 2-dimensional, 4 elements: (1,1), (1,2), (2,1), (2,2)
Dim e(99, 99, 99, 99) As Integer '' 4-dimensional, 100 * 100 * 100 * 100 elements
Deletions:
dim a(1) as integer '' 1-dimensional, 2 elements (0 and 1)
dim b(0 to 1) as integer '' 1-dimensional, 2 elements (0 and 1)
dim c(5 to 10) as integer '' 1-dimensional, 5 elements (5, 6, 7, 8, 9 and 10)
dim d(1 to 2, 1 to 2) as integer '' 2-dimensional, 4 elements: (1,1), (1,2), (2,1), (2,2)
dim e(255, 255, 255, 255) as integer '' 4-dimensional, 256 * 256 * 256 * 256 elements


Revision [21466]

Edited on 2016-05-14 00:50:42 by fxm [Updated description]
Additions:
Fixed-length arrays are [[ProPgArrays|arrays]] that have a fixed constant size throughout the execution of a program. The memory used by a fixed-length array to store its elements is allocated at compile-time, either on the stack or in the ##.BSS## or ##.DATA## sections of the executable, depending on whether ##[[KeyPgStatic|Static]]## (or ##[[KeyPgShared|Shared]]##) was used to define it. This may allow for quicker program execution since the memory for the array is already allocated, unlike [[ProPgVarLenArrays|variable-length arrays]], whose element memory isn't allocated until runtime.
Deletions:
Fixed-length arrays are [[ProPgArrays|arrays]] that have a fixed constant size throughout the execution of a program. The memory used by a fixed-length array to store its elements is allocated at compile-time, either on the stack or in the ##.BSS## or ##.DATA## sections of the executable, depending on whether ##[[KeyPgStatic|Static]]## was used to define it. This may allow for quicker program execution since the memory for the array is already allocated, unlike [[ProPgVarLenArrays|variable-length arrays]], whose element memory isn't allocated until runtime.


Revision [20637]

Edited on 2016-02-10 16:12:48 by DkLwikki [Update link format]
Additions:
Fixed-length arrays are [[ProPgArrays|arrays]] that have a fixed constant size throughout the execution of a program. The memory used by a fixed-length array to store its elements is allocated at compile-time, either on the stack or in the ##.BSS## or ##.DATA## sections of the executable, depending on whether ##[[KeyPgStatic|Static]]## was used to define it. This may allow for quicker program execution since the memory for the array is already allocated, unlike [[ProPgVarLenArrays|variable-length arrays]], whose element memory isn't allocated until runtime.
Fixed-length arrays with //[[ProPgStorageClasses|automatic storage]]//, have their elements allocated on the program stack, and pointers to these elements remain valid only while the array is in scope. The elements of fixed-length arrays with //[[ProPgStorageClasses|static storage]]// are allocated in the ##.DATA## or ##.BSS## sections of the executable, depending on whether or not they are initialized when defined, so pointers to these elements remain valid for the entire execution of the program. Fixed-length arrays of any storage class cannot be resized during program execution, only [[ProPgVarLenArrays|variable-length arrays]] can.
Fixed-length arrays may also be used as data members inside [[ProPgUDTs|user-defined types]], in which case the array is directly allocated as part of the user-defined type structure.
A fixed-length array is declared with either the ##[[KeyPgDim|Dim]]## or ##[[KeyPgStatic|Static]]## keywords, followed by a variable identifier, a parenthesized list of boundaries and an element [[CatPgStdDataTypes|data type]].
For an array to be declared fixed-length, the boundaries must be specified using only number literals or ##[[KeyPgConst|Const]]## values or ##[[KeyPgEnum|Enum]]## constants.
Deletions:
Fixed-length arrays are [[ProPgArrays arrays]] that have a fixed constant size throughout the execution of a program. The memory used by a fixed-length array to store its elements is allocated at compile-time, either on the stack or in the ##.BSS## or ##.DATA## sections of the executable, depending on whether ##[[KeyPgStatic Static]]## was used to define it. This may allow for quicker program execution since the memory for the array is already allocated, unlike [[ProPgVarLenArrays variable-length arrays]], whose element memory isn't allocated until runtime.
Fixed-length arrays with //[[ProPgStorageClasses automatic storage]]//, have their elements allocated on the program stack, and pointers to these elements remain valid only while the array is in scope. The elements of fixed-length arrays with //[[ProPgStorageClasses static storage]]// are allocated in the ##.DATA## or ##.BSS## sections of the executable, depending on whether or not they are initialized when defined, so pointers to these elements remain valid for the entire execution of the program. Fixed-length arrays of any storage class cannot be resized during program execution, only [[ProPgVarLenArrays variable-length arrays]] can.
Fixed-length arrays may also be used as data members inside [[ProPgUDTs user-defined types]], in which case the array is directly allocated as part of the user-defined type structure.
A fixed-length array is declared with either the ##[[KeyPgDim Dim]]## or ##[[KeyPgStatic Static]]## keywords, followed by a variable identifier, a parenthesized list of boundaries and an element [[CatPgStdDataTypes data type]].
For an array to be declared fixed-length, the boundaries must be specified using only number literals or ##[[KeyPgConst Const]]## values or ##[[KeyPgEnum Enum]]## constants.


Revision [17039]

Edited on 2014-04-26 11:36:00 by DkLwikki [Focus on array decl syntax, not decl vs def]
Additions:
There are various ways to specify an array's amount of elements. Each array can have between 1 or 8 dimensions. Each dimension has a lower bound and an upper bound.
Deletions:
There are various ways to specify an array's amount of elements:


Revision [17038]

Edited on 2014-04-26 11:34:28 by DkLwikki [Focus on array decl syntax, not decl vs def]
Additions:


Fixed-length arrays may also be used as data members inside [[ProPgUDTs user-defined types]], in which case the array is directly allocated as part of the user-defined type structure.
{{fbdoc item="section" value="Declaration"}}
A fixed-length array is declared with either the ##[[KeyPgDim Dim]]## or ##[[KeyPgStatic Static]]## keywords, followed by a variable identifier, a parenthesized list of boundaries and an element [[CatPgStdDataTypes data type]].

{{fbdoc item="filename" value="examples/manual/proguide/arrays/fixedlen_storage.bas"}}%%(freebasic)
There are various ways to specify an array's amount of elements:

{{fbdoc item="filename" value="examples/manual/proguide/arrays/fixedlen_bounds.bas"}}%%(freebasic)
dim a(1) as integer '' 1-dimensional, 2 elements (0 and 1)
dim b(0 to 1) as integer '' 1-dimensional, 2 elements (0 and 1)
dim c(5 to 10) as integer '' 1-dimensional, 5 elements (5, 6, 7, 8, 9 and 10)
dim d(1 to 2, 1 to 2) as integer '' 2-dimensional, 4 elements: (1,1), (1,2), (2,1), (2,2)
dim e(255, 255, 255, 255) as integer '' 4-dimensional, 256 * 256 * 256 * 256 elements

For an array to be declared fixed-length, the boundaries must be specified using only number literals or ##[[KeyPgConst Const]]## values or ##[[KeyPgEnum Enum]]## constants.
{{fbdoc item="filename" value="examples/manual/proguide/arrays/fixedlen_constants.bas"}}%%(freebasic)
const myLowerBound = -5
const myUpperBound = 10
'' Declares a one-dimensional fixed-length array, holding myUpperBound - myLowerBound + 1 String objects.
dim arrayOfStrings(myLowerBound to myUpperBound) as string
'' Declares a one-dimensional fixed-length array of bytes,
'' big enough to hold an INTEGER.
dim arrayOfBytes(0 to sizeof(integer) - 1) as byte
Deletions:
{{fbdoc item="section" value="Declaration and definition"}}
A fixed-length array is declared with the ##[[KeyPgExtern Extern]]## keyword, followed by a variable identifier, a parenthesized list of one (1) or more subscript ranges and an element [[CatPgStdDataTypes datatype]]. For an array to be declared fixed-length, either numerical literals, ##[[KeyPgConst Const]]## variables or ##[[KeyPgEnum Enum]]## enumerators can be used as subscript range values.
{{fbdoc item="filename" value="examples/manual/proguide/arrays/fixedlen_1.bas"}}%%(freebasic)
const maxLowerBound as integer = -5
const maxUpperBound as integer = 10
'' Declares a two dimensional fixed-length array of elements of type STRING..
extern arrayOfStrings(maxLowerBound to maxUpperBound, 20) as string
'' Declares a one-dimensional fixed-length array of elements of type BYTE,
'' big enough to hold an INTEGER..
extern arrayOfBytes(sizeof(integer)) as byte
A fixed-length array is defined with either the ##[[KeyPgStatic Static]]## or ##[[KeyPgDim Dim]]## keywords, following the same form as declaration.
{{fbdoc item="filename" value="examples/manual/proguide/arrays/fixedlen_2.bas"}}%%(freebasic)


Revision [11945]

The oldest known version of this page was created on 2007-12-21 14:27:51 by ElSairon [Focus on array decl syntax, not decl vs def]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode