TYPE Statement Action Defines a data type or ISAM table type that contains one or more elements or table columns. Syntax TYPE usertype elementname AS typename elementname AS typename . . . END TYPE Remarks The TYPE statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- usertype A user-defined data type or ISAM table type. The argument usertype follows the same rules as a BASIC variable name. In the case of an ISAM table, usertype identifies a user-defined table structure. elementname An element or table column of the Argument Description ---------------------------------------------------------------------------- elementname An element or table column of the user-defined type. For a data type, elementname follows the same rules as a BASIC variable name. For a table type, elementname follows the ISAM naming conventions. typename A user-defined data type, nested user-defined type (databases only), an array, or one of the following data types. integer, long, single (non-ISAM types only), double, fixed-length string, or currency . If usertype is a table type, any elementname arguments are the names of columns in the table. The names must be exact matches to existing column names and must follow the ISAM naming conventions. Note Line numbers and line labels aren't allowed in TYPE... END TYPE blocks. ISAM names use the following conventions. - They have no more than 30 characters. - They use only alphanumeric characters (A-Z, a-z, 0-9). - They begin with an alphabetic character. - They include no BASIC special characters. Note BASIC now supports user-defined types for ISAM tables, the currency data type for dollars-and-cents math and static arrays in user-defined types. Before you can use an ISAM table, you must declare a record type for the records that make up the table. Instances of this type are used to pass records to and from the table. The following TYPE statement illustrates the use of static arrays. The record StateData includes the CityCode static array, and the record Washington has the same structure as StateData. TYPE StateData CityCode (1 TO 100) AS INTEGER ' Declare a static array. County AS STRING * 30 END TYPE DIM Washington(1 TO 100) AS StateData When you declare a static array within a user-defined type, its dimensions must be declared with numeric constants rather than variables. For efficiency, make sure that arrays within a user-defined type start on even offsets. You can create very large records when you include static arrays within records. Putting one of these records within a SUB procedure can use large amounts of stack space. Strings in user types must be fixed-length strings. String lengths are indicated by an asterisk and a numeric constant. For example, the following line defines an element named Keyword in a user-defined type as a string with length 40. TYPE Keyword AS STRING * 40 END TYPE A user-defined type must be declared in a type declaration before it can be used in the program. Although a user-defined type can be declared only in the module-level code, you can declare a variable to be of a user-defined type anywhere in the module, even in a SUB or FUNCTION procedure. Use the DIM, REDIM, COMMON, STATIC, or SHARED statements to declare a variable to be of a user-defined type. The keyword REM cannot be used as a field name in a TYPE statement. The text that follows REM is treated as a comment. Note If you have defined a table to have columns A, B, C, and D, you can use a user-defined type that has only the columns you need (any subset of A, B, C, and D). See Also OPEN Example See the PUT statement (file I-O) programming example, which uses the TYPE statement.