✔ Appearance ✔ Standard ✔ Console
begin record typeName recDefnBlock end record
July 19, 2000 (Release 3)
Begins the definition of a "true" record type (as opposed to a pseudo-record type, which is defined using the
dim record...dim end record statements). The record type definition must end with an
end record statement.
begin record...end record block is non-executable, so you can't change its effect by putting it inside a conditional execution structure such as
long if/end if. However, you can conditionally include or exclude it from the program by putting it inside a
compile long if block.
The record type defined in the
begin record...end record block is global in scope, and can be used anywhere below where the block appears.
||is a name that identifies the record type. This name must be unique among all defined record types in your program.|
||is a block of one or more
You can also use the following "leading dot" syntax within the record definition block, to declare "empty" space; that is, some bytes within the record which are not identified by any field name:
constant is an integer literal, or a symbolic constant name (without its leading underscore character). This declares the specified number of bytes as being "nameless."
You can also use the "semicolon" syntax after the definition of a field name, in order to specify how many bytes should be skipped between the beginning of this field and the beginning of the following field. You can use this either to insert "nameless" bytes within the record, or to make fields overlap in memory. See the
dim statement for more information about the semicolon syntax.
After a record type has been defined using
begin record...end record, it can be used just like any other data type. This means:
- You can declare variables as having type
- You can declare arrays as having type
- You can declare fields in other record types as having type
Anywhere below the
end record statement, you can use the
dim statement, along with the
as keyword, to declare a variable, array or field of type
typeName. For example, if you have defined a record type called
Address, then you can do the following:
dim myHouse as Address, yourHouse as Address dim relatives(15) as Address begin record EmployeeInfo dim 50 name$ dim 9 socSecNo$ dim 20 hobbies$ dim empAddress as Address end record
After you have declared a variable of a given record type, then you can use the "embedded dot" syntax to refer to individual fields within the record. Using the above example:
dim mySecretary as EmployeeInfo mySecretary.socSecNo$ = "456-78-9999"
Arrays of records and arrays of fieldsEdit
When you use arrays of pseudo-records, you always write the array subscript at the end of the expression, whether the expression indicates an entire record or one of its fields. For example, if we have a pseudo-record array called
game(7) refers to element #7 in the array. If this record type has a field called
score, then we represent the
begin record StudentInfo dim 20 firstName$ dim 20 lastName$ dim 1 finalGrade$ end record dim myStudents(35) as StudentInfo 'This represents the final grade of myStudent #14: myStudents.finalGrade$(14)= "B"
Arrays inside of true recordsEdit
True records have the ability to hold arrays inside of each record. This special embedded array is designated by using a bracket instead of a parenthesis for individual elements. The brackets are used for both dimensioning and accessing the sub-elements.
begin record StudentInfo dim 20 firstName$ dim 20 lastName$ dim grades end record dim myStudents(35) as StudentInfo myStudents.grades(5) = 96
In the final line of this example, the grade element number 1 of student number 5 is set to 96.
No special notes.
dim record...dim end record; dim; begin union; sizeof; offsetof