![]() |
<< Index >> |
FutureBasic |
| dim | statement | |
|
|
||
Syntax 2
Description
A declaration can have any of the following forms:
Simple variables:
Records:
Arrays:
Pointers:
Handles
Memory alignment declarations:
local function (but not within a Certain structures must always be declared in a
byte (`, ``), byte, char, Boolean |
1 byte |
short (%, %`), short, int, SInt16, UInt16 |
2 bytes |
integer (&, &`), SInt32, UInt32 |
4 bytes |
long (&, &`), long, NSInteger, NSUInteger |
8 bytes |
long long SInt64, UInt64 |
8 bytes |
single (!), single |
4 bytes |
double (#), double |
8 bytes |
Str255 |
256 bytes |
pointer |
8 bytes |
Handle |
8 bytes |
(Note the storage space for variables can vary between CPU devices. When in doubt, use the sizeof function to make a definite determination of the size of the variable.)
The storage space allocated for a string variable depends on the value of the maxLen parameter (which cannot exceed 255). If maxLen is omitted, then the most recent maxLen specified in the same as Str255 clause always have a maxLen value of 255.
Once maxLen has been determined for a given string variable, the actual number of bytes allocated for the variable is:
maxLen + 1 bytes, if maxLen is odd;
maxLen + 2 bytes, if maxLen is even;
maxLen characters to a string variable. The storage space for a record variable equals the sum of the lengths of the record's fields, or the value of constant2 (in bytes).elSize is the size in bytes of a single array element, then the space allocated for the entire array is given by the following expression:array size = elSize * (maxSub1 + 1) * (maxSub2 + 1) * ...
All the elements in an array are stored in contiguous locations in memory. If the array is multi-dimensional, then the rightmost dimensions change most rapidly as you step through the elements' locations in memory. For example, if you declare an array as follows:
Then the elements of p() are stored in this order in memory:
p(0,1)
p(0,2)
p(1,0)
p(1,1)
p(1,2)
p(2,0)
p(2,1)
p(2,2)
p(3,0)
p(3,1)
p(3,2)
Inline assignment
When using the
Simple variables:
dim as long value = 12
long value = 12
Multiple simple variables:
dim as CFStringRef s1 = @"One" , s2 = @"Two" , s3 = @"Three"
CFStringRef s1 = @"One" , s2 = @"Two" , s3 = @"Three"
Records:
A record's field values must be enclosed in braces
CGPoint pt = { 14, 13 }
Subrecords must also be enclosed in braces
ItemInfo info = { 54321, 23, { 12.34, 17.53 }, 9 }
Aliased variables
Aliased variables are no longer supported. For example, the following syntax cannot be used:
See also
begin globals; begin record; blockvar; static