Accessing the fields of a User-Defined Type

To work with the individual fields within a record variable, separate the field name from the variable name with a period. Here are some examples using the Student variable in the above DIM statement:

Last$ = Student.LastName

Message$ = "Id number is: " + STR$(Student.IdNum)

Student.FirstName = "Bob"

Student.LastName = "Smith"

Fullname$ = Student.LastName + " " + Student.FirstName

Fullname$ = RTRIM$(Student.LastName) + ", " + RTRIM$(Student.FirstName)

Note that the last two statements above produce slightly differing results. The former produces a string that contains the text plus any $SPC (space) characters that pad the text in each of the Student.LastName and Student.FirstName members. Comparatively, the latter statement returns a string with these padding characters removed. In many cases, it can be easier to use a nul-terminated string members to alleviate the need to frequently trim such fixed-length strings, but allowance must be made for the additional $NUL terminator byte required by nul-terminated strings.

See Also

User-Defined Types (UDTs)

Defining User-Defined Types

Accessing the fields of a User-Defined Type

Nesting User-Defined Types

Arrays within User-Defined Types

Using arrays of User-Defined Types

Using User-Defined Types with procedures

Storage requirements and restrictions

Unions