PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • When should I use the indirection?
  • Identifying the current object
  • Indirection on a structure
  • Using the indirection on the paths in an XML document
  • Limitations
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
The { and } operators are used to access a control, a variable, a class member or a file item by dynamically building the name of control, variable, class member or item.
The { and } operators present several benefits:
  • Passing in parameter the name of a control, variable, class member or item.
  • Building the name of a control, variable, class member or item by programming.
AndroidAndroid Widget The indirections are not supported by the local variables. The indirections are supported by the global variables only. An indirection on a local variable of a process will trigger an "unknown element" error.
Versions 16 and later
Universal Windows 10 App This feature is available for Windows Phone applications.
New in version 16
Universal Windows 10 App This feature is available for Windows Phone applications.
Universal Windows 10 App This feature is available for Windows Phone applications.
Versions 17 and later
iPhone/iPad This feature is available for iPhone/iPad applications.
New in version 17
iPhone/iPad This feature is available for iPhone/iPad applications.
iPhone/iPad This feature is available for iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
New in version 18
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Versions 21 and later
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
New in version 21
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Example
// Simple indirection
{"NAME"} = CustName               // Is equivalent to NAME=CustName
{"NAME"} = {"CU.CUSTNAME"}        // Is equivalent to NAME=CU.CUSTNAME
{"CUSTWIN.NAME"} = CustName        // Is equivalent to CUSTWIN.NAME=CustName
{"CUSTWIN"+".NAME"} = CustName     // Is equivalent to CUSTWIN.NAME=CustName
 
// Typed indirection
{"Name",indControl} = CustName
 
// Indirection with a file name in a variable
nFileName is string = "Customer"
{nFileName + ".Name"} = "Smith"
HAdd({nFileName})
// Indirection in a procedure
ControlName is string
ControlName = "EDT_EDIT1" // EDT_EDIT1 is the name of the control
// Call to a procedure used to make a control invisible
Make_Invisible(ControlName)
 
PROCEDURE Make_Invisible(ControlN)
{ControlN}..State = Invisible
// Indirection with variable
AliasName is string
AliasName = PreviousWin()
// NAME is the name of the control
// CustName is the value to assign
{AliasName+".NAME"} = CustName
Abbrev is string
ItemName is string
{Abbrev+"."+ItemName} = CustName
{Abbrev+"."+ItemName} = {ControlName}
// Declare a class with two members
MyClass is Class
Member1 is string
Member2 is string
// Display the value of a member
GLOBAL procedure DisplayMember(Number)
// Retrieve the value of the selected global member
Value is string = {"::Member"+Number}
Info(Value)
Versions 16 and later
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 Word version
New in version 16
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 Word version
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 Word version
Syntax

Simple indirection Hide the details

{ <Expression> }
<Expression>: Character string
Expression used to identify the control, the variable or the item to use. The element is sought:
  • among the variables,
  • according to the number of dots found in the name:
    • 0 dot: search among the controls, then the HFSQL items.
    • 1 dot: search among the HFSQL items, the controls, then the query parameters.
    • greater than 1 dot: search among the controls.
  • among the special elements kept for compatibility (_Tabx for example, ...).
A WLanguage error occurs if this expression corresponds to an empty string ("").

Indirection on a class member Hide the details

{ <Expression> }
<Expression>: Character string
Expression used to identify the class member.
If the member is:
  • global, use the following syntax: {" :: MemberName"}
  • not global, use the following syntax: {" : MemberName"}
A WLanguage error occurs if this expression corresponds to an empty string ("").
Versions 16 and later

Indirection on a class member Hide the details

{ <Class> , <Member> }
<Class>: Character string
Class instance
<Member>: Character string or Variable Description variable
Corresponds to:
New in version 16

Indirection on a class member Hide the details

{ <Class> , <Member> }
<Class>: Character string
Class instance
<Member>: Character string or Variable Description variable
Corresponds to:

Indirection on a class member Hide the details

{ <Class> , <Member> }
<Class>: Character string
Class instance
<Member>: Character string or Variable Description variable
Corresponds to:

Indirection by specifying the element type (optimizes the execution speed) Hide the details

{ <Expression>, <Type> }
<Expression>: Character string
Expression used to identify the control, the variable or the item to use. A WLanguage error occurs if this expression corresponds to an empty string ("").
<Type>: Constant
Constant used to specify the type of sought element:
indControlElement sought among the controls and the groups.
indConnectionElement sought among the connections.
indReportElement sought among the reports.
indWindowElement sought among the windows.
indFileElement sought among the files.
indGPWElement sought among the elements of user groupware (used to retrieve the initial status of controls).
indLinkElement sought among the links.
indQueryParameterElement sought among the parameters of queries.
indItemElement sought among the items.
indVariableElement sought among the variables.
AndroidAndroid Widget The element is only sought within the global variables.
indPageElement sought among the pages.
Remarks

When should I use the indirection?

The indirection can be used for example:
  • To access the value of an element (control, variable, item, ...):
    {s_ControlName} = 10
    ControlValue = {s_ControlName}
  • To use a property:
    {s_ControlName}..Height = 10
  • To handle a column of a memory table:
    {s_ColumnName, indControl}[Row_Number] = 10
  • To handle a table column:
    {s_TableName + "." +s_ColumnName, indControl}[Row_Number] = 10
Universal Windows 10 AppAndroidAndroid Widget iPhone/iPad

Identifying the current object

To identify the current object, use the following keywords:
  • MySelf: the current control
  • MyWindow: the current window
  • MyPage: the current page
    Universal Windows 10 AppAndroidAndroid Widget iPhone/iPad This keyword is not available.
  • MyReport: the current report
    AndroidAndroid Widget This keyword is not available.
  • MySource: the current data source.
  • MyFile: the file that released the current trigger.
Universal Windows 10 AppiPhone/iPad

Indirection on a structure

An indirection cannot contain an access to a structure or to a class instance. However, the following syntax can be used:
{<Structure Variable>}: member
Universal Windows 10 AppiPhone/iPad

Using the indirection on the paths in an XML document

The indirection operators can be used to build the path of an element in an XML document.
Example:
sDocXML is string = [
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<InfoVersion>
<Version>21</Version>
<Millesime>2016</Millesime>
</InfoVersion>
</Document>
]
 
xmlExemple is xmlDocument = XMLOpen(sDocXML, fromString)
 
sParam is string = "WinDev_Param"
 
// Lecture directe d'une information ...
Trace(xmlExemple.Document.InfoVersion.Version)
 
// Lecture avec une partie du chemin XML contenu dans une variable
// (idem si rubrique d'un fichier, paramètre d'une fenêtre, méthode, ...)
sParamètre is string = "InfoVersion"
Trace({"xmlExemple.Document." + sParamètre + ".Version"})
Universal Windows 10 AppiPhone/iPad

Limitations

The indirection operator allows you to find an element by its name.
Therefore, the following operations are not allowed in an indirection:
  • access to a member of a class instance or structure instance other than the instance of current class (: and:: ).
  • access to a sub-element of control or array ([] operator).
  • access to a sub-part of string ([[]] operator).
  • access to a property (.. operator).
  • indirection ({ } operator).
  • call to a procedure or to a method of Automation object.
  • declaring a variable.
Remarks:
  • The operators for accessing an element (: and [] and [[]] and .. ) can be used on the element obtained by indirection. For example:
    { <indirection> }: member

    { <indirection> } [subscript]

    { <indirection> } [[ subscript ]]

    { <indirection> }..property
  • To call a procedure identified by its name, use Execute or ExecuteProcess.
  • To combine these operations dynamically, you have the ability to use the dynamic compilation (see Compile).
Related Examples:
The indirections Unit examples (WINDEV): The indirections
[ + ] Handling indirections via the { and } operators.
The { and } operators are used to access a control or a file item by dynamically building the control name or the item name.
This program, powered by WINDEV, implements the indirection mechanism on the window controls to manage the "Undo-Redo" and "Cut-Copy-Paste" features in a generic way.
The indirections Unit examples (WEBDEV): The indirections
[ + ] This example explains how to use the indirections on a variable.

You will notice that the indirections are available for the controls, the items, the links, etc. The principle is identical to the one presented in this example.
The indirections Unit examples (WINDEV Mobile): The indirections
[ + ] Using the indirection { and } operators.
The { and } operators are used to access a control or a file item by dynamically building the control name or the item name.
This example implements the indirection mechanism on the window controls to manage the "Undo-Redo" and "Cut-Copy-Paste" features in a generic way.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment