ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Declaring variables
  • Passing a fixed array as a parameter to a procedure
  • Declaring a fixed array member
  • Dimension of a fixed array
  • Fixed array of arrays, associative arrays, queues, stacks and lists
  • Limits: Elements of a fixed array
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
A fixed array is an "advanced" type of array: its dimensions are fixed at compile time and cannot be modified.
The dimensions of a fixed array are set at compile time only if they correspond to:
  • an integer,
  • a previously created constant.
Otherwise, a WLanguage error occurs when the project is compiled.
Reminder: An array is a structured type used to group together a series of elements of the same type.. Each element of the array can be accessed by its index.
It is recommended to use:
  • A fixed array to pass an array as a parameter to the Windows API functions.
  • A dynamic array or a "simple" array if the array needs to be resized during the execution of the program.
  • An associative array to index elements by any type of value.
Example
// Declare a fixed array
CustomerArray is fixed array of 5 by 7 by 3 int
// Equivalent to: TableauClient is a fixed array of 5,7,3 integers
// Refer to a fixed array
CustomerArray[2,5,3] = 47
// Equivalent to: TableauClient[2][5][3] = 47
Syntax

Declaring a fixed array (syntax 1)


<Nom du tableau> is [a] fixed array [ <Dimension 1> [,<Dimension 2>... [,<Dimension 10>]] ] <Type des éléments du tableau>
Example:
arrString is fixed array [10] strings
arrInt is fixed array [5,9] int

Declaring a fixed array (syntax 2) Hide the details

<Nom du tableau> is a fixed array of <Dimension 1> [by <Dimension 2>... [by <Dimension 10>]] <Type des éléments du tableau>

OR

<Nom du tableau> is a fixed array of <Dimension 1> [,<Dimension 2>... [,<Dimension 10>]] <Type des éléments du tableau>
<Array name>:
Name of the array variable to be declared.
<Dimension 1>...<Dimension 10>:
Dimensions of the array from 1 to 10 (integer).
<Type of array elements>:
Type of the elements in the array. See the different WLanguage types.
WINDEVWEBDEV - Server codeWindowsLinuxiPhone/iPadIOS WidgetApple WatchMac Catalyst Note: The elements making up the array can also be arrays, fixed arrays, associative arrays, queues, stacks or lists..
Remark: The keyword un is not mandatory: it's an approval word.

Referencing an element in a fixed one-dimensional array:

<Array name>[Index1]

Referencing an element in a fixed two-dimensional array:

<Array name>[Index1, Index2]

OR

<Array name>[index1][index2]

Referencing an element in a fixed N-dimensional array:

<Array Name>[Subscript1, ... , SubscriptN]

OR

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

Passing an array as a parameter to a procedure: Hide the details

<Procedure name>(<Array name>)
<Array name>:
Name of the fixed array to be used.
<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).
Remark: It is not possible to manipulate an array in its entirety.. For example, an array cannot be assigned to another array.
Remarks

Passing a fixed array as a parameter to a procedure

A fixed array can be passed as a parameter to a procedure. To do so, use the following syntax:
<Procedure name>(<Array name>)
For example:
SupplierArray is fixed array of 10 by 50 string
// Call to the DisplayArray procedure
DisplayArray(SupplierArray)

Declaring a fixed array member

A "fixed array" member can be declared in:
  • A class. The fixed array is directly allocated in the class memory area.
  • A composite variable. The fixed array is directly allocated in the memory area of the composite variable.
  • A structure <Structure name>. The fixed array is directly allocated in the memory area of each <Structure name> variable.
For example:
Struct is TO Structure
	n1 is int
	nArray is fixed array of 2 int
	n2 is int
END
MyStructure is Struct
Representation of the memory area of "MyStructure":
This memory representation is compatible with the Windows APIs. Therefore, a fixed-size array can be passed to a Windows API function.

Dimension of a fixed array

The Dimension function and the Count property are used to get the number of elements in a fixed array.
Reminder It is not possible to resize a fixed array.
WINDEVWEBDEV - Server codeWindowsLinuxiPhone/iPadIOS WidgetApple WatchMac Catalyst

Fixed array of arrays, associative arrays, queues, stacks and lists

The following syntaxes are supported:
<variable> is fixed array of 5 arrays of int
<variable> is fixed array of 5 arrays of 5 int

<variable> is fixed array of 5 fixed arrays of 5 int

<variable> is fixed array of 5 associative arrays of int
<variable> is fixed array of 5 associative arrays (withDuplicates) of int
<variable> is fixed array of 5 associative arrays (withDuplicates,wlInt) of int

<variable> is fixed array of 5 queues of int

<variable> is fixed array of 5 stacks of int

<variable> is fixed array of 5 lists of int

Limits: Elements of a fixed array

  • A fixed array can include classes only if these classes have a constructor without parameters (or with optional parameters).
  • A fixed array cannot include composite variables.
  • AndroidAndroid Widget JavaPHP A fixed array cannot include arrays.
  • Java It is not possible to create fixed arrays of classes or structures.
  • The size of a fixed array cannot exceed 2GB.
Minimum version required
  • Version 9
This page is also available for…
Comments
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 Jul. 2019

Last update: 10/04/2024

Send a report | Local help