qck.hlp (Table of Contents; Topic list)
AS Declaration Statements
                                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 AS Declaration Statements
 
 ■ In general, AS clause syntax is:
 
         declare variablename AS type
 
   where declare can be DIM, COMMON, FUNCTION, SHARED, or STATIC, and type
   can be any valid data type (default is SINGLE). For example, the following
   statement declares the variable A as having a long-integer type:
 
         DIM A AS LONG
 
 ■ If you declare a variable with an AS clause, every declaration of the
   variable must use the AS clause. For example, in the following code, AS
   is required in the COMMON statement because AS is used in the DIM
   statement:
 
         CONST MAXEMPLOYEES = 250
         DIM EmpNames(MAXEMPLOYEES) AS STRING
         COMMON EmpNames() AS STRING
         .
         .
         .
 
   See: COMMON Statement  DIM Statement
 
 ■ String variables declared in an AS STRING clause can be either:
   • Variable-length (depends on the length of the string assigned)
   • Fixed-length (length is specified by adding "* number" to the AS STRING
     clause, where number is the length of the string in bytes)
 
   For example:
 
         DIM String1 AS STRING      'String1 can have a variable length
         DIM String2 AS STRING*7    'String2 has a fixed length of 7 bytes
         String1  = "1234567890"
         String2  = "1234567890"
         PRINT String1
         PRINT String2
 
   produces this output:
 
         1234567890
         1234567
 
 ■ User-defined (or record) variables can be declared by specifying the name
   of the record variable in the AS clause of a declaration:
 
         TYPE InventoryItem                 'Declare group as single type
              Description AS STRING * 25    'Declare fixed-length string
              Number AS STRING * 10         'Declare fixed-length string
              Quantity AS LONG              'Declare long (4-byte) integer
              OrderPoint AS LONG            'Declare long (4-byte) integer
         END TYPE
         .
         .
         .
         DIM CurrentItem AS InventoryItem, PreviousItem AS InventoryItem
 
   See: TYPE Statement
 
 ■ To refer to individual elements of the new variable, use the dot (.)
   notation form:
 
         variablename.elementname
 
   For example:
 
         IF CurrentItem.Description = "Ergonomic Desk Chair" THEN
              PRINT CurrentItem.Number; CurrentItem.Quantity
         END IF
 
 See: Variables Summary