Dim v As Gfa_Var
A Gfa_Var item provides read-only properties that allow you to get information about the variable like its name, type, location, and value. Changing a variable's value during runtime must be accomplished by using direct memory access using Poke and its variants.
| Property | Description |
|---|---|
| Name | The name of the variable |
| Pname | The name of the procedure the variable is declared. |
| Type | A value indicating the variable type (basInt, basFixedStr, etc)[1] |
| TypeName | A string describing the variables type (Integer, String, user-defined). For ByRef parameters or Pointer variables a Ref precedes the type name ("Ref Integer"). With constants "Const Int". |
| Value | The current value of the variable. |
| VarPtr | The address of the variable. In contrast with Addr with ByRef and Pointer variables, the physical address of the variable is returned. |
| Addr | The address of the variable. For Ref variables the address of the pointer. |
| Size | Returns the memory size of the variable (Integer: 4 bytes, Double: 8 bytes). |
| Len | Same as Size, but returns the length for a string. |
| IsArray | Returns True when the variable is an array. |
| ArrayAddr | The address of the first byte of the array. |
| ArraySize | The allocated memory for the array. |
| IndexCount | The number dimensions (See IndexCount in the Help). |
| LBound(n) | Returns the smallest available subscript for the specified dimension n of the array. |
| UBound(n) | Returns the largest available subscript for the specified dimension n of the array. |
| IsObject | Returns True when the variable is of type Object. |
| IsHash | Returns True when the variable is a Hash type. |
| Count | Returns the number of elements of the Hash variable. |
| IsTyped | Returns True when the variable is a user defined type. |
| TypeObj | Returns a Gfa_Type object for the variable when IsTyped is True. |
Note: For ParamArray parameter .Type returns 250, .TypeName "ParamArray()", and .IsArray returns False, because a ParamArray isn't a normal array. The .Value property returns a variant array, so that the elements of the ParamArray are accessed using .Value(Idx).
The .Type property returns a 32-bit value indicating the type of variable. For the basic data types, these values are represented with a constant starting with 'bas'.
| Constant | Value | TypeName |
|---|---|---|
| basEmpty | 0 | Empty |
| basNull | 1 | Null |
| basShort | 2 | Short (16-bit Integer (&)) |
| basLong | 3 | Long (32 bit integer (%)) |
| basInt | 3 | Long (32 bit integer (%)) |
| basSingle | 4 | Single (4 byte floating point (!)) |
| basDouble | 5 | Double (8 byte floating point (#)) |
| basCurrency | 6 | Currency (@) |
| basDate | 7 | Date |
| basVString | 8 | String (in Variant) |
| basObject | 9 | Type of Object ("Command", "Font", "Collection", etc., but also "Nothing") |
| basError | 10 | Error |
| basBoolean | 11 | Boolean (Value 0 or -1 (?)) |
| basVariant | 12 | Variant (used only with arrays of Variants) |
| basByte | 17 | Byte (|) |
| basLarge | 20 | Large |
| 243 | Const Int | |
| 244 | Const Double | |
| 245 | Const Single | |
| 246 | Const Date | |
| 247 | Const Large | |
| 248 | Const Currency | |
| 249 | Const String | |
| 250 | ParamArray() | |
| basType | 251 | user defined Type |
| basHash | 252 | Hash |
| basFixedStr | 253 | Fixed String |
| basUnknown | 254 | unknown |
| basString | 255 | String ($) |
| basArray | 8192 | Array |
When .Type is basObject and the object refers to a late binding object, .TypeName returns the name of the server.
Dim o As Object
Set o = CreateObject("Word.Basic")
Print TypeName(o) // returns "wordbasic".
Note Individual variables can be examined within a 'normal' program as well. A GLL isn't required to inspect variables, a Tron proc may display additional information also. The required GFA-BASIC 32 functions are identical to the Gfa_Var properties. For instance, to obtain a variable's type you would use VarType(var), to get a named description use TypeName(var), when a variable is an array, its characteristics are obtained using ArrayAddr, Dim?, etc.
{Created by Sjouke Hamstra; Last updated: 08/10/2014 by James Gaite}