AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Sintaxis WLanguage / Operadores
  • When should indirection be used?
  • Identifying the current object
  • Indirection on a structure
  • Using the indirection on the paths in an XML document
  • Limitations
  • Indirections in Java
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Operators { and operators } operators are used to access a field, variable, class member or data file item by dynamically constructing the name of the field, variable, class member or item.
The { and } operators present several benefits:
  • Passing as parameter the name of a control, variable, class member or item.
  • Building the name of a control, variable, class member or item programmatically.
WEBDEV - Código Servidor To use an indirection on a control of a page, the option "Permitir indirecciones (ralentiza la ejecución)" must be checked ("Details" tab in the control description window).
AndroidWidget Android Java Indirections cannot be performed local variables. Indirections can only be performed on global variables only. An indirection on a local variable of a process will trigger an "unknown element" error.
Ejemplo
// 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 data 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)
{NChamp}..Status = 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)
c is cWord
var is Variable Description
Def is Definition

Def = GetDefinition(c)
// Get the 2nd variable of the class: Word version
var = Def..Variable[2]

Trace(var..Name) // Displays the variable name
Trace("Word version: ",{c, var}) // Display Word version
Sintaxis

Simple indirection Ocultar los detalles

{ <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 point: search among fields, then HFSQL items.
    • 1 point: search among HFSQL items, fields, then query parameters.
    • greater than 1 point: search among fields.
  • 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 Ocultar los detalles

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

Indirection on a class member Ocultar los detalles

{ <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) Ocultar los detalles

{ <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.
PHP This constant is not available in PHP.
indWindowElement sought among the windows.
PHP This constant is not available in PHP.
indFileItem searched for in data files.
indGPWElement sought among the elements of user groupware (used to retrieve the initial status of controls).
PHP This constant is not available in PHP.
indLinkElement sought among the links.
PHP This constant is not available in PHP.
indQueryParameterElement sought among the parameters of queries.
indItemElement sought among the items.
indVariableElement sought among the variables.
AndroidWidget Android JavaPHP The element is only sought within the global variables.
indPageElement sought among the pages.
PHP Only the current page is accessible.
Observaciones

When should indirection be used?

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 programmatically handle a column of a Table control:
    {s_ColumnName, indControl}[Row_Number] = 10
  • To handle a table column:
    {s_TableName + "." +s_ColumnName, indControl}[Row_Number] = 10
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsAndroidWidget Android iPhone/iPadJavaCódigo de Usuario (UMC)

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
    AndroidWidget Android iPhone/iPadJava This keyword is not available.
  • MyReport: the current report
    AndroidWidget Android Java This keyword is not available.
  • MySource: the current data source.
  • MyFile: the data file that triggered the current trigger.
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsiPhone/iPadJavaCódigo de Usuario (UMC)

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:
{<Variable structure>}: member
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsiPhone/iPadJavaCódigo de Usuario (UMC)

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:
sXMLDoc is string = [
	<?xml version="1.0" encoding="UTF-8"?>
	<Document>
	<VersionInfo>
	<Version>21</Version>
	<Year>2016</Year>
	</VersionInfo>
	</Document>
]

xmlExample is xmlDocument = XMLOpen(sXMLDoc, fromString)

sParam is string = "WINDEV_Param"

// Direct reading of information ...
Trace(xmlExample.Document.VersionInfo.Version) 

// Reading with part of XML path found in a variable
// (idem if file item, window parameter, method, ...)
sParameter is string = "VersionInfo"
Trace ({"xmlExample.Document." + sParameter + ".Version"})
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsiPhone/iPadJavaCódigo de Usuario (UMC)

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 other than the current class instance (operators: and:: ).
  • access to a subelement in a control or array ([] operator).
  • access to a substring ([[]] operator).
  • access to a property (.. operator).
  • indirection ({ } operator).
  • call to a procedure or to a method of Automation object.
  • declaring a variable.
Remarks:
  • Access operators on an element (operators: and [] and [[]] and . ) can be used on the element obtained by indirection. For example:
    { <indirection> }: member

    { <indirection> } [index]

    { <indirection> } [[ index ]]

    { <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).
Java

Indirections in Java

Indirections are not supported by local variables.
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Example
In Button
ExibeData(MyPage..Name +"."+FSTC_fecha..Name)


In procedure global
PROCEDURE ExibeData(myfecha)

mesEspanhol is string

dHoje is Date = Today()

SWITCH dHoje..Month
CASE 1
mesEspanhol = "enero"
CASE 2
mesEspanhol = "febrero"
CASE 3
mesEspanhol = "marzo"
CASE 4
mesEspanhol = "abril"
CASE 5
mesEspanhol = "mayo"
CASE 6
mesEspanhol = "junio"
CASE 7
mesEspanhol = "julio"
CASE 8
mesEspanhol = "agosto"
CASE 9
mesEspanhol = "setiembre"
CASE 10
mesEspanhol = "octubre"
CASE 11
mesEspanhol = "noviembre"
CASE 12
mesEspanhol = "diciembre"
OTHER CASE
mesEspanhol = ""
END

{myfecha} = dHoje..Day +" de "+ mesEspanhol +" de "+ dHoje..Year
Boller
11 09 2024
Example Use
//exemplo de indirection
gJanela01 is string = gJanela + "."+gLooper+"["+gLinha+"]."+gAttFoto
{gJanela01,indControl} = gsCheminDernièreCapture

HReset(pomv_parte_objeto_mov_local)
Busca is Buffer = HBuildKeyValue(pomv_parte_objeto_mov_local,chavecomposta, gEquipamento,gRegid_cab,gRegid_Item)
IF HReadSeek(pomv_parte_objeto_mov_local,chavecomposta,Busca,hIdentical) = True
IF HFound(pomv_parte_objeto_mov_local) = True
pomv_parte_objeto_mov_local.e001_id = gEquipamento
pomv_parte_objeto_mov_local.pocb_id = gRegid_cab
pomv_parte_objeto_mov_local.poit_id = gRegid_Item
pomv_parte_objeto_mov_local.pomv_data_emi = DateSys()+TimeSys()
pomv_parte_objeto_mov_local.pomv_foto = dLoadImage(gsCheminDernièreCapture,imgDefault)
IF HModify(pomv_parte_objeto_mov_local) = True THEN
gJanela01 = gJanela + "."+gLooper
LooperDisplay({gJanela01,indControl},taInit)
END
END
END
Boller
15 04 2021

Última modificación: 08/12/2024

Señalar un error o enviar una sugerencia | Ayuda local