Gfa_Type and Gfa_Types

Syntax

Dim type As Gfa_Type

Dim types As Gfa_Types

Description

A Gfa_Type item contains the properties that allow you to get information about a user-defined type like its name, elements, and their type.

Property Description
Count Returns the number of elements of the type.
Name(n) The name of the element n in the user-defined type. Name(0) returns the name of the Type itself.
Index(e$) Returns the index of element e$.
Size(n) Returns the memory size of element n in bytes.
Type(n) A value indicating the type of element n (basInt, basFixedString, etc)
TypeName(n) A string describing the type of element n (Integer, String)
Offset(n) Returns the offset from the start of element n in bytes
BitSize(n) Returns the memory size element n in bits
BitOffset(n) Returns the offset of element n from the beginning of the type in bits.
TypeObj(n) Returns a Gfa_Type object for the element when Type(n) > 65535.
IsArray(n) Returns True when the element is an array. False for a Variant containing an array.
LBound(n) Returns the smallest available subscript for the specified dimension of the array
UBound(n) Returns the largest available subscript for the specified dimension of the array
ArrSize(n) The allocated memory for the array in bytes.

Obtaining type information is important when you develop a custom debugger. However, the type information can be obtained at design time as well. The following example shows all user defined types currently in use in your program. If you perform a syntax check before pressing App + T, the Gfa_Types collection provides the type elements as well.

Gfa_Types is a collection containing Gfa_Type items. A Gfa_Type item contains information about a user-defined type.

The Gfa_Types collection allows you to enumerate over all types defined in the program.

Dim t As Gfa_Type

For Each t In Gfa_Types

Debug t.Name(0)

Next

Example

Enumerate all Types in a program.

 

Sub Gfa_App_T

Debug.Show

Dim udt As Gfa_Type, i%

For Each udt In Gfa_Types

Try

Debug "Type ";udt.Name(0)

For i = 1 To udt.Count

Debug "  ";udt.Name(i);

If udt.IsArray(i) Then

Debug "(";udt.LBound(i);"..";udt.UBound(i);")";

EndIf

Debug " As ";udt.TypeName(i);#9;" // Type: ";udt.Type(i)

Next

Debug "EndType"

Catch

Debug "Error in Print_type ";Err;Err$

EndCatch

Next

Debug "- Did you perform a syntax check first?"

' Sample

Type test

tstl(6 .. 7) As Long

tsts As String*20

rc(2) As RECT

EndType

Type RECT

- Int32 left, top, right, bottom

EndType

EndSub

Remarks

According to German documentation the .Type property returns a variant-type constant. When .Type = VT_I4 the variable is an integer and when .Type is VT_I4 | VT_BYREF a ByRef Integer Parameter.
VT_I4 | VT_ARRAY is a global or static Integer array, VT_I4 | VT_BYREF | VT_ARRAY a local Integer array or a ByRef Integer array parameter.
The same is true for VT_I2 (Short) VT_UI2 (Card), VT_UI1 (Byte), VT_BOOL (Boolean), VT_R4 (Single), VT_R8 (Double), VT_DATE (Date), VT_VARIANT (Variant), VT_CY (Currency) and VT_I8 (Large). With user-defined types the property is a value greater than 4 billion, with ByRef a user-defined type parameter is odd, otherwise even.

See Also

Gfa_Var, Gfa_Vars

{Created by Sjouke Hamstra; Last updated: 08/10/2014 by James Gaite}