Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
User-Defined Data Types
◄Data Types► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
User-Defined Data Types
BASIC lets you define new data types using the TYPE statement. A user-
defined type, also called a record, is an aggregate type made up of
elementary BASIC types. Elements of a user-defined type can be different
data types. For example, the following TYPE statement defines a
type, InventoryItem:
TYPE InventoryItem
Quantity AS LONG
OrderPoint AS LONG
Cost AS CURRENCY
VendorCodes(1 TO 10) AS INTEGER
Description AS STRING*25
Number AS STRING*10
END TYPE
The new type InventoryItem contains two long integers, one currency item,
a static array of integers, and two fixed-length strings. A variable of
a user-defined type occupies only as much storage as the sum of its
components. InventoryItem takes up 71 bytes: 4 bytes each for the two long
integers (8 bytes total), 8 bytes for the currency item, 20 bytes for the
static array, and 35 bytes for the fixed-length strings.
You may use any of the BASIC data types (except variable-length strings) in
a user-defined type: short and long integers, single- and double-precision
floating-point values, currency, fixed-length strings, static arrays, and
other user-defined types. User-defined types cannot include variable-length
strings or dynamic arrays.
Data Types in ISAM Files
Some special restrictions apply to BASIC ISAM files. When you create an
ISAM table, you create a user-defined data type by including an appropriate
TYPE...END TYPE statement in the declarations part of your program.