![]() |
<< Index >> |
FutureBasic 5 |
| 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 |
| signed byte | 1 byte | -128..+127 | x' Dim x As Byte Dim x As Char |
| unsigned byte | 1 byte | 0..255 | x`` Dim x As Unsigned Byte Dim x As Unsigned Char |
| signed short integer | 2 bytes | -32768..+32767 | x% Dim x As Int Dim x As Word Dim x As Short |
| unsigned short integer | 2 bytes | 0..65535 | x%` Dim x As Unsigned Int Dim x As Unsigned Word Dim x As Unsigned Short |
| long integer | 4 bytes | -2147483648..+2147483647 | x& Dim x As Long |
| Unsigned long integer | 4 bytes | 0..4294967295 | x&` Dim x As Unsigned Long |
17.3 -62. 0.03
mantissa{E|e}exponent
mantissa is a string of decimal digits with an optional decimal point, optionally preceded by "+" or "-"; exponent is a string of decimal digits, optionally preceded by "+" or "-".3e-20 -6.7E4 0.05E+14mantissa 10exponentdim 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 Integersizeof 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. Example:print "I said, ""Hello."""I 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 stringsprint a$ = b$ the result will be zero (_false) or -1 (_zTrue). We have provided a substitute function that can handle the comparison for you.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$$.hndl& = [@myContainer$$]a$$ = %resID% : rem fill container with text res ID resID%
a$$ = &hndl& : rem fill container with contents of hndl&c$$ = c$$ + left$$(a$$,10)d$$ = c$$ + a$c$$ += left$$(a$$,10)d$$ = c$$
d$$ += a$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. You can use a long integer variable to store the same address as a pointer variable, and for many purposes pointer variables and long integer variables are interchangeable.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. You can use a long integer variable to store the same address as a handle variable, and for many purposes handle variables and long integer variables are interchangeable.dim statement, using the following syntax:dim recordName.constconst is either an integer literal, or a symbolic constant name (minus its leading underscore character). A pseudo-record variable occupies const bytes of storage, and can contain any kind of data. You use the recordName.offset[.offset...]typeSuffix syntax to access the "fields" of a pseudo-record variable (see Appendix B - Variables). Typically you define the offset constants using a dim record...dim end record block.dim recordName as recordTypebegin 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 true-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.