80
Private isCurrent as Boolean
End Structure
Sub Main()
Dim ts as MyTimeStamp
Call GetTimeStamp(ts.tdate.year, ts.tdate.month, ts.tdate.day, _
ts.ttime.hour, ts.ttime.minute, ts.ttime.seconds)
End Sub
The example above illustrates how members of an instance of a structure are referenced. The variable
ts is an instance of the MyTimeStamp structure. A member is referenced by appending the member
name to the variable name, separating them with a period. For members that are structures, members of
the subordinate structure are referred to similarly. No spaces are allowed in this construction. In cases
where a variable or a member is an array, the index list directly follows the variable/member name,
preceding the period.
Structure foo
Dim b as Byte
Dim ai(1 to 10) as Integer
Dim ts(1 to 4) as MyTimeStamp
End Structure
Dim yr as UnsignedInteger
Dim i as Integer
Dim f as foo
Dim b as Byte
i = f.ai(b)
yr = f.ts(3).tdate.year
The address of a member of a variable that is a structure may be obtained by appending the
.DataAddress property identifier to the reference or by using the MemAddress() function.
Dim addr as UnsignedInteger
addr = ts.tdate.DataAddress
addr = MemAddressU(ts.tdate)
Structures may be used in Alias and Based variable definitions. However, in these cases the structures
may not contain members that are any of the string types. Structures may be passed to subroutines and
functions either by reference or by value. If a structure is passed by value, the structure will be read-only
within the procedure.
A variable that is a structure may be assigned to another variable that is the same type of structure using
the standard assignment operator as long as the structure does not contain any members that have the
allocated string type. In contrast, assignment of structures with members that are fixed-length or
bounded strings is supported. Likewise, two variables that are the same type of structure may be
compared for equality or inequality using the standard comparison operators, = and <>. The
equality/inequality test is implemented using a byte-by-byte comparison of the content of two structures.
If one or more members of the structure are the BoundedString type, the byte-by-byte comparision may
result in a False value even though the strings are identical. This is because the currently-unused portion
of the string store may contain byte values that are different between the two instances being compared.
Similarly, comparison of structures containing allocated strings, while allowed, is not recommended
because of the likelihood of resulting in false negatives.
Structures may contain members that are sub-byte types, Bit and Nibble. Members that are Bit type
will be aligned on the next available bit boundary and those that are Nibble type will be aligned on the
next available nibble boundary. If a member that is not a sub-byte type follows a sub-byte type member,
that non-sub-byte member will be aligned on the next available byte boundary. Depending on how you
define your structure, this may result in holes in the structure layout representing unused bits. The