Click or drag to resize

IvarList Function

Store all instance variables of an object into an array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.6
Syntax
 FUNCTION IvarList(
	oObject AS Object
) AS ARRAY
Request Example View Source

Parameters

oObject
Type: Object
The object containing the instance variable to store.

Return Value

Type: Array
An array of symbols containing the name of all instance variables and access methods of <oObject>.
Remarks
This conversion can offer you additional flexibility in manipulating data and can allow you to utilize powerful array functions, such as AEval() and AScan().
The scope throughout the function call is SELF.
Examples
This example uses IVarList() to store INSTANCE and EXPORT instance variables into an array.
It then prints the stored instance variables.  (Note that the password is not stored in the array because it is a protected instance variable.)
X#
 1CLASS Person
 2    EXPORT name
 3    INSTANCE grade
 4    PROTECT password
 5CONSTRUCTOR(tname, tgrade, tpassword)
 6    name := tname
 7    grade := tgrade
 8    password := tpassword
 9END CLASS
10
11FUNCTION MakeArray() AS VOID
12    LOCAL x AS OBJECT
13    LOCAL a AS ARRAY
14    x := Person{"Randal", "A", "123"}
15    a := IVarList(x)
16    // Print them
17    FOR i := UPTO ALen(a)
18        QOut(a[i])
19    NEXT
20                        // NAME
21                        // GRADE
See Also