Dim vs As Gfa_Vars
Set vs = Gfa_Vars(subcol$)
The Gfa_Vars collection object represents all or part of the variables used in an application. A Gfa_Vars collection consists of Gfa_Var items. A Gfa_Var item contains the properties that allow you to get information about the variable like its name, type, location, and value.
The only way to obtain a Gfa_Vars collection object, is by invoking the function Gfa_Vars(subcol$) that returns a Gfa_Vars collection as specified in the function's parameter value. For instance
Dim globalvars As Gfa_Vars
Set globalvars = Gfa_Vars("") ' the global variables
The parameter designates the sub collection of variables. The parameter is of type Variant and can be one of the following values:
Parameter | Returns a Gfa_Vars collection object with | Alias |
---|---|---|
"" | All global variables.. | Gfa_Globals |
"-" | All local and static variables of the main program. | |
"Procname" | All local and static variables of the specified procedure. The name is case sensitive! | Gfa_Vars!Procname |
"1" or 1 | All local and static variables of the current procedure. Available in Gfa_Tron and Gfa_TronBook proc only. | Gfa_Vars1 or Gfa_Vars!1 |
"2" or 2 | All local and static variables of the caller of the current procedure. Available in Gfa_Tron and Gfa_TronBook proc only. | Gfa_Vars2 or Gfa_Vars!2 |
"3" or 2 … n | All local and static variables of the caller (of the caller …) of the caller of the current procedure. Available in Gfa_Tron and Gfa_TronBook proc only. | Gfa_Vars3, Gfa_Vars4, …, Gfa_Vars9 or Gfa_Vars!n |
When the parameter is the empty string "", a dash "-", or an explicit procedure name, the collection of variables can be created anywhere in the GLL. However, the numbered Gfa_Vars collections are relative to the stack and are available only in the Gfa_Tron or Gfa_TronBook procedures.
Note: To obtain variables at a depth level of more than 9, then you must use the variant that takes a parameter: Gfa_Vars("12").
Each instance of a Gfa_Vars collection has the following properties:
Property | Description |
---|---|
PName | The name of the procedure that is specified as the parameter in the Gfa_Vars() function. This property most interesting for the stack based collections to obtain the name of the procedure that is being executed. |
Count | The number of items in the collection. |
Item() | A Gfa_Var object for the specified variable. |
Availability at design-time
After compiling or performing a syntax-check the Gfa_Vars collection is available, as well. The syntax-check (or Run command) collect all variables and the variables are available in the non-stack based Gfa_Vars() function. The following piece of code displays the name and type of all global variables in the Debug Output window (don't forget to compile your program first).
Sub Gfa_App_V
Dim v As Gfa_Var, GlobVars As Gfa_Vars
Set GlobVars = Gfa_Vars("")
For Each v In GlobVars
Debug v.Name & #32 & v.Type & #32 & v.TypeName
Next
EndSub
To access the variables of a procedure specify the name (case sensitive) of the procedure as the parameter of Gfa_Vars().
Set vs = Gfa_Vars!Gfa_App_V ' using ! notation
The name of function may contain a type modifier %, $, &, @, or |. Only ! is forbidden.
Set vs = Gfa_Vars!Calculate@ ' variables of function Calculate@()
{Created by Sjouke Hamstra; Last updated: 08/10/2014 by James Gaite}