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 / Declaración de variables
  • Deleting a dynamic array (optional)
  • Passing a dynamic array as parameter to a procedure
  • Declaring a dynamic array member
  • WLanguage functions and dynamic arrays
  • Limits: Elements of a dynamic array
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
A dynamic array is an "advanced" type of array: the dimensions of this array are allocated upon request during the execution of the program. In most cases, a "simple" array is sufficient.
Reminder: An array is a structured type that is used to group a set of elements of the same type. Each element of the array can be accessed by its index.
It is recommended to use:
  • A dynamic array or a "simple" array when the size of the array must be modified during the program execution.
  • A fixed array for the Windows APIs.
  • An associative array to store the elements indexed on any type of information.
Ejemplo
// Declare a dynamic array
CustomerArray is dynamic array
// Allocate a dynamic array
CustomerArray is dynamic array
 
CustomerArray = new array of 4 by 7 int
// Equivalent to: CustomerArray = new array of 4,7 int
// (From version 17) Equivalent to: CustomerArray = new array [4,7] int
// Refer to a dynamic array
CustomerArray[2,5,3] = 47
// Equivalent to: CustomerArray[2][5][3] = 47
Sintaxis

Declaring a dynamic array Ocultar los detalles

<Name of dynamic array> is dynamic array
<Name of dynamic array>:
Name of the dynamic array variable to declare.

Allocate a dynamic array (syntax 1)


<Name of dynamic array> = new array [ <Dimension 1> [,<Dimension 2> ... [<Dimension 10>]] ] <Type of array elements>
Example:
TableauClient is array dynamic
TableauClient = new array [4,7] int

Allocate a dynamic array (syntax 2) Ocultar los detalles

<Name of dynamic array> = new array of <Dimension 1> [by <Dimension 2> ... [by <Dimension 10>]] <Type of array elements>

OR

<Name of dynamic array> = new array of <Dimension 1> [,<Dimension 2> ... [,<Dimension 10>]] <Type of array elements>
<Name of dynamic array>:
Name of the dynamic array to use. This array was declared beforehand.
<Dimension 1>...<Dimension 10>:
Dimension 1 to 10 of the array (integer value equal to or greater than 0).
<Type of array elements>:
Type of the elements found in the array. See The different types of WLanguage.

Turning reference into a dynamic array

Remark: To refer to a dynamic array, this array must be allocated.

Referring to a one-dimensional dynamic array

<Array name>[Index1]

Referring to an element in a two-dimensional array:

<Array name>[Index1, Index2]

OR

<Array name>[index1][index2]

Referring to an element in an array with N dimensions

<Array name>[Index1,...,IndexN]

OR

<Array name>[Index1]...[IndexN]

Passing an array as parameter to a procedure: Ocultar los detalles

<Procedure name>(<Array name>)
<Array name>:
Name of the dynamic array to use.
<Index1>:
Index of the element for the 1st dimension.
<Index2>:
Index of the element for the 2nd dimension.
<IndexN>:
Index of the element for the Nth dimension (N <= 10).
Observaciones

Deleting a dynamic array (optional)

A dynamic array is automatically deleted at the end of the lifetime of the variable (e.g., when the window is closed) or when new dimensions are allocated.
To delete a dynamic array, use the following syntax:
libérer <Nom du tableau dynamique>
If the dynamic array is declared and allocated in the same line of code, you should not use the Release keyword to delete the dynamic array. A runtime error will occur if Release is used.

Passing a dynamic array as parameter to a procedure

A dynamic array can be passed as parameter to a procedure. To do so, use the following syntax:
<Nom de la procédure>(<Nom du tableau>)
For example:
SupplierArray is dynamic array
SupplierArray = new array of 10 by 50 character strings
// Call to the DisplayArray procedure
DisplayArray(SuppArray)

Declaring a dynamic array member

A "dynamic array" member can be declared in:
  • a structure,
  • a composite variable,
  • a class.
The dynamic array must be allocated after the declaration of the structure or composite variable.
For example:
// Declare a structure
Struct is Structure
x1 is int
x2 is dynamic array // Declare the array
END

// Declare a structure variable
MyStruct is Struct
// Allocate the array
x2 = new dynamic array of 4,7 int
For a class, the declaration must be done in the declaration code of the class and the allocation must be cone in the class constructor.

WLanguage functions and dynamic arrays

Several WLanguage functions can be used to handle the dynamic arrays. You have the ability to perform sorts, searches, ... For more details, see Array functions.

Limits: Elements of a dynamic array

  • A dynamic array can be made of classes only if these classes have a constructor without parameter (or with optional parameters).
  • A dynamic array cannot include:
    • composite variables,
    • arrays.
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Example Array [N,X]
//Example Array [N,X]

arrMensajes is array of 1 by 3 strings

i is int = 1

SQLExec(sQuery,ds)

WHILE SQLFetch(ds) = 0
arrMensajes[i,1] = SQLGetCol(ds, 1) //id
arrMensajes[i,2] = SQLGetCol(ds, 2) //numero
arrMensajes[i,3] = SQLGetCol(ds, 3) //mensaje
i++
Dimension(arrMensajes, i, 3)
END
BOLLER
17 07 2019

Última modificación: 06/03/2024

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