![]() |
<< Index >> |
FutureBasic |
Appendix C - Data Types and Data Representation | appendix | |
|
7244 -328442
&
" or "&H
" or "0x
" (that's a zero-x). Hexadecimal digits include the digits 0 through 9, and the letters A
through F
. Letters can be either in upper or lower case. &H12a7 0x47BeeF &42AD9
&O
" (that's the letter "O
", not a zero). Octal digits include the digits 0 through 7. &o70651 &o32277
&x
". Binary digits include the digits 0and1. &x0100011 &x10110000111011001
_"text" _"N*"
begin enum
...end enum
block; or a dim record
...end record
block; or by using a "constant declaration" statement. A constant declaration statement has this syntax:_constantName = staticExpression
_constantName
is a symbolic constant which has not been previously defined, and staticExpression
is a "static integer expression" (see Appendix D - Numeric Expressions). The value of staticExpression
must be within the range -2,147,483,648 through +2,147,483,647. Once a symbolic constant has a value assigned to it, that value cannot be changed within your program. Like all constants, a symbolic constant has a global scope._constantName$ = "I am a string constant"
_constantTab$ = 9 : rem chr$(9) = tab character
_constantCR$ = 13 : rem chr$(13) = carriage return
_twoByteKanjiChar = 10231: rem KCHR$(10231)
as
clause in a dim
statement. If a variable has no type-identifier suffix, and wasn't declared with an as
clause, then FutureBasic checks whether there are any def<type>
statements which are applicable to the variable. Finally, if the variable can't be typed by any of the above means, FutureBasic assigns the type "signed short integer" to the variable. Arrays of integers, and integer record fields, are typed by similar means.Type | Storage | Range | Type identification |
byte | 1 byte | -128..+127 | x x |
unsigned byte | 1 byte | 0..255 | x |
short integer | 2 bytes | -32768..+32767 | x x |
unsigned short integer | 2 bytes | 0..65535 | x x |
int | 4 bytes | -2147483648..+2147483647 | x |
unsigned int | 4 bytes | 0..4294967295 | x |
long integer | 8 bytes | -9223372036854775808..+9223372036854775807 | x |
unsigned long integer | 8 bytes | 0..18446744073709551615 | x |
17.3 -62. 0.03
3e-20 -6.7E4 0.05E+14
dim
statement, using the as Fixed
clause. It's accurate to about 5 places past the decimal point, and can handle numbers in the range of approximately -32767.99998 through +32767.99998. A fixed-point variable occupies 4 bytes of storage.as
clause in a dim
statement. If a variable has no type-identifier suffix, and wasn't declared with an as
clause, FutureBasic checks whether there are any defsng <letterRange>
or defdbl <letterRange>
statements which are applicable to the variable. Floating-point arrays, and floating-point record fields, are typed by similar means.//
// Required Floating Point Constants //
//
_NumberLeadingSpace = _true //FBII Default = _true
_RoundUpFloat2Long = _true // Un-remark to round up Float to Integer
sizeof
function to make a definite determination of the size of the variable.)
Type |
Type Identification |
single-precision |
x! (4 bytes)dim x as single |
double-precision |
x# (8 bytes)dim x as double |
data
statements, the quotation marks may be optional). If the string literal contains a pair of contiguous double-quotes, they are interpreted as a (single) embedded double-quote mark and treated as part of the string, rather than as a delimiter. ExampleI said, "Hello."
$
" to the variable's name; alternatively, you can declare a variable as a string by using the as Str255
clause in a dim
statement. If a variable has no type-identifier suffix, and wasn't declared with an as
clause, then FutureBasic checks whether there are any defstr <letterRange>
statements which are applicable to the variable. String arrays, and string record fields, are typed by similar means.as Str255
can hold up to 255 characters. The maximum number of characters that other string variables can represent is determined by the maxLen
value specified in a dim
statement, or by the value specified in the DEFLEN
statement. If neither of these values was specified, then the string variable can hold a string of up to 255 characters.sizeof
function to determine the number of bytes allocated to a particular string variable.dim myContainer$$
) or in a dim as
statement (dim as CONTAINER myContainer
).myContainer$$ = ""
.myContainer$$ = a$ + b$ + c$
myContainer$$ = a$
myContainer$$+= b$
myContainer$$+= c$
a$$ = b$$ + c$$
a$$ = b$$ + c$$ + 0 : rem math
a$$ = b$$ + c$$ + "" : rem strings
print a$ = b$
the result will be zero (_false) or -1 (_zTrue).rslt& = fn FBCompareContainers(a$$,b$$)
rslt&
is zero, the containers are equal.rslt&
is positive, it points to the character position at which it was determined that a$$ is greater than b$$.p = fn ContainerToPointer( @myContainer )
which replaces the previous handle-based version ( i.e. hndl& = [@myContainer$$]
)fn ContainerFromPointer( @myContainer, p, size )
this replaces the previous handle-based version ( i.e. a$$ = &hndl&
)c$$ = c$$ + left$$(a$$,10)
d$$ = c$$ + a$
c$$ += left$$(a$$,10)
d$$ = c$$
d$$ += a$
c$$ = right$$( a$$, 8 ) + left$$( b$$, 3 )
c$$ = right$$( a$$, 8 )
c$$ += left$$( b$$, 3 )
dim
statement. It can be declared using the as pointer
(or as PTR
) clause, or an as ptrType
clause, where ptrType is a type which was previously identified as a pointer
type (in a #define
statement). If the as pointer
clause included a to
clause, then the variable is identified as "pointing to" a data structure of the indicated type; otherwise it's considered a "generic" pointer._nil
(zero), which indicates that the pointer currently isn't "pointing to" anything.dim
statement. It can be declared using the as Handle
(or as HNDL
) clause, or an as hdlType
clause, where hdlType
is a type which was previously identified as a Handle
type (in a #define
statement). If the as Handle
clause included a to
clause, then the variable is identified as a handle to a data structure of the indicated type; there are also a couple of pre-defined types (RgnHandle
and TEHANDLE
) which are recognized as handles to particular types of MacOS structures (specifically: to regions and TextEdit records). If the variable is declared simply "as Handle
" (with no to
clause), it's considered a "generic" handle._nil
(zero), which indicates that it doesn't currently refer to any data structure.begin record
...end record
block. In addition, FutureBasic recognizes two built-in record types: Rect
and Point
. You use the recordName.field
syntax to access the fields of a record variable (see Appendix B - Variables).Values Variables | Sign. Byte | Uns. Byte | Sign. Byte | Uns. Byte | Sign. Byte | Uns. Byte | Fixed | Simple | Double | String | Pointer | Handle | Record |
Sign. Byte | OK | 2 | 2 | 2 | 2 | 2 | 2,3 | 2,3 | 2,3 | 2,3,8 | NO | NO | NO |
Uns. Byte | 1 | OK | 1,2 | 2 | 1,2 | 2 | 1,2,3 | 1,2,3 | 1,2,3 | 1,2,3,8 | NO | NO | NO |
Sign. Word | OK | OK | OK | 2 | 2 | 2 | 3 | 2,3 | 2,3 | 2,3,8 | NO | NO | NO |
Uns. Word | 1 | OK | 1 | NO | 1,2 | 2 | 1,3 | 1,2,3 | 1,2,3 | 1,2,3,8 | NO | NO | NO |
Sign. Long | OK | OK | OK | OK | OK | 2 | 3 | 2,3 | 2,3 | 2,3,8 | 10 | 10 | NO |
Uns. Long | 1 | OK | 1 | OK | 1,2 | OK | 1,3 | 1,2,3 | 1,2,3 | 1,2,3,8 | 10 | 10 | NO |
Fixed | OK | OK | OK | 2 | 2 | 2 | OK | 2,4 | 2,4 | 2,4,8 | NO | NO | NO |
Simple | OK | OK | OK | OK | 4 | 4 | 4 | OK | 4 | 4,8 | NO | NO | NO |
Double | OK | OK | OK | OK | OK | OK | OK | OK | OK | 8 | NO | NO | NO |
String | 5,8 | 5,8 | 5,8 | 5,8 | 5,8 | 5,8 | 5,8 | 5,8 | 5,8 | 5 | 5,8 | 5,8 | NO |
Pointer | OK | OK | OK | OK | OK | OK | 2,3 | 2,3 | 2,3 | 2,3,8 | 6 | NO | NO |
Handle | OK | OK | OK | OK | OK | OK | 2,3 | 2,3 | 2,3 | 2,3,8 | OK | 7 | NO |
Record | NO | NO | NO | NO | NO | NO | NO | NO | NO | NO | NO | NO | 9 |
val[&]
or str$
functions.