PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Inserting an element into an array
  • Inserting an element into an advanced array property
  • Inserting an element into a list
  • Inserting an array
  • Inserting a list
  • Use conditions
  • Various
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 WLanguage array.
  • into an associative array.
  • into an advanced array property (array of gglCalendar events, ...).
  • into a WLanguage list.
This function can also be used to concatenate two arrays or two lists.
Notes:
  • This function is equivalent to ArrayInsert.
  • WEBDEV - Browser codePHP This function can only be used with the Array and Associative Array variables.
Versions 16 and later
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
WEBDEV - Browser code This function is now available in browser code.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
AndroidAndroid Widget Java This function is now available for the List variables.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
WEBDEV - Browser code This function is now available in browser code.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
AndroidAndroid Widget Java This function is now available for the List variables.
Apple Watch This function is now available in Apple Watch mode.
WEBDEV - Browser code This function is now available in browser code.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
AndroidAndroid Widget Java This function is now available for the List variables.
Example
MyArray is array of 2 strings
Insert(MyArray, 1, "WINDEV")
Insert(MyArray, 2, "WEBDEV")
Insert(MyArray, 3, "WINDEV and WEBDEV")
// Display the content of the 3th element
Trace(MyArray[3]) // Displays "WINDEV and WEBDEV"
MyArray is array of 2 strings
MyArray[1] = "WINDEV"
MyArray[2] = "WEBDEV"
Insert(MyArray, 3, "WINDEV and WEBDEV")
// Display the content of the 3th element
Trace(MyArray[3]) // Displays "WINDEV and WEBDEV"
// Associative array Last Name - First Name
aaLastNameFirstName is associative array of strings
Insert(aaLastNameFirstName, "Smith", "Tommy")
Insert(aaLastNameFirstName, "Montgomery", "Julia")
Syntax

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

Insert(<Array Name> , <Insertion Subscript> [, <Element Value>])
<Array Name>: 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 the 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 or Add).
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 array at the specified 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

Insert(<Array Name> , <Element Key> , <Element Value>)
<Array Name>: 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 will be inserted into the specified array.

Inserting an array into an array Hide the details

Insert(<Array Name> , <Insertion Subscript> [, <Name of Array to Insert>])
<Array Name>: 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 the 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.
<Name of Array to Insert>: Optional array
Array that will be inserted into <Array Name>. This insertion will be performed at the specified insertion subscript.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Inserting an element into a list Hide the details

Insert(<List Name> , <Insertion Subscript> , <Element Value>)
<List Name>: List
Name of List variable to use.
<Insertion Subscript>: Integer constant
Subscript where the element will be inserted into the list. The following constants can be used:
FirstElementThe element is inserted at the beginning of list.
LastElementThe element is inserted at the end of list.
BeforeCurrentElementThe element is inserted before the current element.
This constant is available when browsing the list elements only.
Caution: The element will be browsed by the next iteration if the loop is a descending loop.
AfterCurrentElementThe element is inserted after the current element.
This constant is available when browsing the list elements only.
Caution: The element will be browsed by the next iteration if the loop is an ascending loop.
<Element Value>: Any type
Element that will be inserted into the list at the specified position.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Inserting a list into a list Hide the details

Insert(<List Name> , <Insertion Subscript> , <Name of List to Insert>)
<List Name>: List
Name of List variable to use.
<Insertion Subscript>: Integer constant
Subscript where the list will be inserted into the list. The following constants can be used:
FirstElementThe list is inserted at the beginning of <List Name>.
LastElementThe list is inserted at the end of <List Name>.
BeforeCurrentElementThe list is inserted before the current element.
This constant is available when browsing the list elements only.
AfterCurrentElementThe list is inserted after the current element.
This constant is available when browsing the list elements only.
<Name of List to Insert>: List
List that will be inserted at the specified insertion subscript.
Remarks

Inserting an element into an array

When using Insert:
  • 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 (Insert), 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.

Inserting an element into an advanced array property

When using Insert:
  • the advanced variable must be allocated.
  • 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 using Insert:
  • the list is automatically enlarged to receive the new element.
  • the element is converted (if necessary) into the type of the other list elements.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP This feature is not available.
WEBDEV - Browser codePHP This feature is not available.

Inserting an array

When using Insert:
  • 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 using Insert:
  • 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.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP This feature is not available.
WEBDEV - Browser codePHP This feature is not available.

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 Insert.
This function cannot be used on:
  • the non-allocated arrays,
  • the fixed arrays.

Various

  • 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.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
WEBDEV - Browser code WDJS.DLL
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment