bas7advr.hlp (Topic list)
TYPE Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
TYPE defines a data type or ISAM table type that contains one or more
elements or table columns.
 
TYPE usertype
  elementname AS typename
  [elementname AS typename]
.
.
.
END TYPE
    ■ The usertype follows the same rules as a BASIC variable name. In the
      case of an ISAM table, the argument usertype identifies a user-defined
      table structure.
    ■ For a data type, elementname follows the same rules as a BASIC
      variable name. For a table type, elementname follows the ISAM naming
      conventions.
    ■ If the argument 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.
    ■ The typename can be a user-defined data type, a nested user-defined
      type (data types only), or an array.
 
New Features
    ■ BASIC now supports:
        - User-defined types for ISAM tables.
        - The currency data type for dollars and cents math.
        - 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   'declares 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.
 
Usage Notes
    ■ 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 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.
    ■ 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 is treated as a comment.
 
ISAM Programming Tip
    ■ 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).