ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / OOP (Object Oriented Programming)
  • Overview
  • How to?
  • Operations performed via ExecuteProcess and via the indirection operators
  • Using ExecuteProcess
  • Using the indirection operators { ... }
  • Example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
Several types of WLanguage variables are used to enumerate and dynamically handle the elements of a class. A developer who is familiar with Object-Oriented Programming (OOP) can create custom methods that adapt to the elements found in a class.
You have the ability to enumerate:
During this enumeration, you will have the ability to retrieve:
  • the element name.
  • the type of the element.
For example:
  • ability to retrieve the name of a method in order to call it by using ExecuteProcess.
  • ability to retrieve the name and type of a variable to find out or assign its value by using the indirection operators { }.
How to?
The different steps for enumerating and handling an object are as follows:
  1. Retrieving the definition of the object to handle via GetDefinition.
    Example:
    O is cWord    // Instantiation of the CWord class
    Def is Definition // Declaration of a Definition variable
     
    Def = GetDefinition(O)  // Retrieve the definition of the O object in the Def variable
     
    Trace(Def..Name)  // Display the name of the object
    Trace(Def.DefinitionFamily)
    Trace(Def.Type) // Display the type of the object
  2. Retrieving the list of methods. A "FOR EACH" loop is used to read the Procedure property of the Definition variable. This property corresponds to an array containing all the procedures found in the described object.
    Example:
    // Declaration of the variable that will contain the description of a procedure
    Proc is procedure Description  
     
    // List of procedures (or methods) of the Def object
    FOR EACH Proc OF Def.Procedure
    Trace (Proc.Name)  // Displays the name of the procedure found
    END

    You can access other properties by using the PropertyName property on the object. For more details, see Procedure Description.
  3. Retrieving the list of properties. A FOR EACH loop is used to read the Property property. This property corresponds to an array containing all the properties found in the described object.
    Example:
    // Declaration of a variable that will contain the description of a property
    Prop is Property Description  
     
    // List of properties of the Def object
    FOR EACH Prop OF Def.Property  
    Trace (Prop.Name)  // Displays the name of the property found
    END

    You can access other properties by using the PropertyName property on the object. For more details, see Property Description.
    You can also use PropertyExist to determine if a specific property exists in a class.
  4. Retrieving the list of variables. A FOR EACH loop is used to read the Variable property. This property corresponds to an array containing all the variables found in the described object.
    Example:
    // Declaration of the variable that will contain the description of a variable
    Prop is Variable Description  
     
    // List of variables of the Def object
    FOR EACH Var OF Def.Variable  
    // Displays the name and type of Variable found
    Trace (Var.Name, Var.Declaration.Type, Var.Definition.Name)
    END

    You can access other properties by using the PropertyName property on the object. For more details, see Variable Description.
Operations performed via ExecuteProcess and via the indirection operators

Using ExecuteProcess

ExecuteProcess is used to call the code of an event associated with an object.
For example, the following code provokes the call of the click code of the Validate button:
ExecuteProcess(ValidateButton, trtClick)
To execute a class method, simply use a variable of type "Procedure Description" with ExecuteProcess.
For example:
c is BalloonTip
p is procedure Description
Def is Definition
 
Def = GetDefinition(c)
// Retrieves the first procedure of the BalloonTip object
p = Def.Procedure[1]  
 
// Runs the procedure represented by p of the c object
ExecuteProcess(c, p)

Using the indirection operators { ... }

The indirection operators { } are used to handle the content of a variable by indirect addressing: the name of the object to address is found in a variable.
The syntax is as follows:
{Variable_containing_Object_name, VariableType}
where VariableType is a constant of the language starting with indXXX.
Example:
// Fills the "EDT_CITY" control with "Montpellier"
ControlName is string
ControlName = "EDT_CITY"
{ControlName, indControl} = "Montpellier"
To handle a member of a class method, all you have to do is pass in { }:
  • the instance of the class
  • a Variable Description variable or the name of the member.
For example:
c is cWord
var is Variable Description
Def is Definition
 
Def = GetDefinition(c)
// Retrieves the 2nd variable of the class: version of Word
var = Def.Variable[2]
 
Trace(var.Name) // Displays the variable name
Trace("Version of Word: ",{c, var})  // Displays the version of Word
Example
The code example below is used to enumerate all the procedures, properties and variables found in a class. In this example, the cWord class is issued from the "WD Controlling Word" example (supplied with WINDEV).
o is cWord
def is Definition
def = GetDefinition(o)
 
Trace(def.Nom)
Trace(def.DefinitionFamily)
Trace(def.Type)
 
Proc is procedure Description
Prop is Property Description
Var is Variable Description
 
Trace("--------------- Procedures --------------------")
FOR EACH Proc OF def.Procedure
Trace(Proc.Global, Proc.Inherited, Proc.Name, Proc.Virtual)
END
 
Trace("--------------- Properties --------------------")
FOR EACH Prop OF def.Property
Trace(Prop.Declaration, Prop.Definition, Prop.Write, ...
Prop.Global, Prop.Inherited, Prop.Read, Prop.Name, Prop.Virtual)
END
 
Trace("--------------- Variables --------------------")
FOR EACH Var OF def.Variable
Trace(Var.Name, Var.Definition.Type, Var.Definition.Name)
SWITCH Var.Definition.Type
CASE 1, 4, 8, 19
// Display the value of the variable via indirection
Trace({o,Var})  
CASE 34 // array
Trace("Dimension: ", {o,Var.Nom}..Count)
CASE 36 // structure
v is Variable Description
Trace("Structure " + Var.Definition.Name)
Trace("........................................................")
FOR EACH v OF Var.Definition.Variable
Trace(v.Name, v.Definition.Type, v.Definition.Name)
END
Trace("........................................................")
OTHER CASE
 
END
Trace("======================================================================")
END
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help