PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Inserting an element into an array
  • Adding an element into an advanced array property
  • Inserting an element into a list
  • Inserting an array
  • Inserting a list
  • Use conditions
  • Miscellaneous
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Inserts an element at a given position:
  • into a one-dimensional array.
  • into an associative array.
  • into an advanced array property (array of gglCalendar events, etc.).
  • into a WLanguage list.
This function can also be used to concatenate two arrays or two lists.
Notes:
  • This function is equivalent to Insert.
Example
MyArray is array of 2 strings
ArrayInsert(MyArray, 1, "WINDEV")
ArrayInsert(MyArray, 2, "WEBDEV")
ArrayInsert(MyArray, 3, "WINDEV and WEBDEV")
// Display the content of 3rd element
Trace(MyArray[3]) // Displays "WINDEV and WEBDEV"
MyArray is array of 2 strings
MyArray[1] = "WINDEV"
MyArray[2] = "WEBDEV"
ArrayInsert(MyArray, 3, "WINDEV and WEBDEV")
// Display the content of 3rd element
Trace(MyArray[3]) // Displays "WINDEV and WEBDEV"
// Associative array Last Name - First Name
aaLastNameFirstName is associative array of strings
ArrayInsert(aaLastNameFirstName, "Smith", "Tommy")
ArrayInsert(aaLastNameFirstName, "Montgomery", "Julia")
Syntax

Inserting an element into an array or into an advanced array property Hide the details

ArrayInsert(<WLanguage array> , <Insertion subscript> [, <Element value>])
<WLanguage array>: Array
Name of Array variable to use. This array must be a one-dimensional array.
<Insertion subscript>: Integer
Subscript where the element will be inserted into the array. From this subscript, all elements will be moved by 1 element.
If <Insertion Subscript> is equal to the number of array elements +1, the element is added at the end of array (equivalent to ArrayAdd).
A WLanguage error occurs if <Insertion subscript> is greater than the number of array elements +1.
<Element value>: Any type, optional
Element that will be inserted into the specified array, at the given position. If this parameter is not specified, the array is enlarged with the default value of the type of the other array elements.

Inserting an element into an associative array Hide the details

ArrayInsert(<WLanguage array> , <Element key> , <Element value>)
<WLanguage array>: Array
Name of Array variable to use. This array must be a one-dimensional array.
<Element key>: Type of key in the associative array
Value of key for which the element will be inserted. In an associative array without duplicate, a WLanguage error occurs if the element already exists.
<Element value>: Any type
Element that must be added to the specified array.

Inserting an array into an array Hide the details

ArrayInsert(<WLanguage array> , <Insertion subscript> [, <Array to insert>])
<WLanguage array>: Array
Name of Array variable to use. This array must be a one-dimensional array.
<Insertion subscript>: Integer
Subscript where the element will be inserted into the array. From this subscript, all elements will be moved by 1 element.
If <Insertion Subscript> is equal to the number of array elements +1, the element is added at the end of the array (equivalent to ArrayAdd).
A WLanguage error occurs if <Insertion subscript> is greater than the number of array elements +1.
<Array to insert>: Optional array
Name of the Array variable to insert at the insertion subscript specified in <WLanguage array>.
Remarks

Inserting an element into an array

When ArrayInsert is called:
  • the array is automatically enlarged to receive the new element.
  • the element is converted (if necessary) into the type of the other array elements.
When declaring an array of N elements, this array contains N empty elements. For example, the array declared below contains 3 empty strings.
MyArray is array of 3 strings
When inserting an element (ArrayInsert), this element is automatically inserted among the elements already found in the array.
In our example, the array will contain 4 elements once the insertion is performed.

Adding an element into an advanced array property

When ArrayInsert is called:
  • the advanced variable must be created.
  • the advanced type must have an enumerator of modifiable collection type.
  • the advanced type is automatically enlarged to receive the new elements.
  • the element is initialized with the value passed in parameter. If no value is passed in parameter, the element is initialized with the default value of the type of the array elements.

Inserting an element into a list

When ArrayInsert is called:
  • the list is automatically enlarged to receive the new element.
  • the element is converted (if necessary) into the type of the other list elements.

Inserting an array

When using ArrayInsert:
  • the array is automatically resized to receive the new elements. The elements of <Name of array to insert> are added at the position specified in <Array name>.
  • the two arrays must have the same type.
  • the arrays must have the same dimension.
  • the values of array dimensions (except for the first one) must be identical.

Inserting a list

When ArrayInsert is called:
  • the list is automatically enlarged to receive the new elements. The elements of <Name of list to insert> are added at the specified position.
  • the two lists must have the same type.

Use conditions

This function can be used with the structures. In this case, you must:
  1. Declare a variable (same type as the structure).
  2. Initialize each member.
  3. Pass the structure variable in parameter to ArrayInsert.
This function cannot be used on:
  • non-created arrays
  • fixed arrays.

Miscellaneous

  • To add an element at the end of a one-dimensional array, use ArrayAdd or Add.
  • To add an element into a sorted array (while respecting the sort), use ArrayAddSorted.
Component : wd240vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment