PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Adding an element into a WLanguage array
  • Adding an element into an advanced array property
  • Adding an element into a list
  • Adding an array into an array (concatenation)
  • Adding a list into a list (concatenation)
  • Adding the content of a structure into an array of structures without using a variable of this structure
  • 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
Adds an element in last position:
  • of a one-dimensional WLanguage array.
  • of an advanced array property (array of gglCalendar events, array of Word Processing document, etc.).
  • from a WLanguage list.
This function can also be used to concatenate two arrays or two lists.
Notes:
  • This function is identical to Add.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for Windows Phone applications.
Universal Windows 10 App This function is now available for Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for 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.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
MyArray is array of 2 strings
ArrayAdd(MyArray, "WINDEV")
ArrayAdd(MyArray, " WEBDEV")
ArrayAdd(MyArray, "WINDEV and WEBDEV")
// Display the content of 3rd element (the first 2 elements are empty)
Trace(MyArray[3])  // Displays "WINDEV"
MyArray is array of 2 strings
MyArray[1] = "WINDEV"
MyArray[2] = "WEBDEV"
ArrayAdd(MyArray, "WINDEV and WEBDEV")
// Display the content of 3rd element
Trace(MyArray[3]) // Displays "WINDEV and WEBDEV"
Syntax

Adding an element to an array, to an advanced array property or to a list Hide the details

<Result> = ArrayAdd(<WLanguage variable> [, <Value>])
<Result>: Integer
Subscript at which the specified element was added. If an error occurs, a fatal error is displayed.
<WLanguage variable>: Array or List
Name of variable to use. This variable can be:
  • An Array variable.
  • A List variable.
<Value>: Type of array elements, optional
Value that will be added to the array or to the list. This parameter is mandatory for a list.
For an array, if this parameter is not specified, the array is enlarged with the default value of the type of the other array elements.

Concatenating arrays or lists Hide the details

<Result> = ArrayAdd(<WLanguage variable> [, <WLanguage variable to concatenate>])
<Result>: Integer
Subscript at which the specified element was added. If an error occurs, a fatal error is displayed.
<WLanguage variable>: Array or List
Name of variable to use. This variable can be:
  • An Array variable.
  • A List variable.
<WLanguage variable to concatenate>: Optional array or list
Name of variable that will be added after the existing elements. This variable can be:
  • An Array variable, to concatenate two arrays. This array must be a one-dimensional array.
  • A List variable, to concatenate two lists.
Remarks

Adding an element into a WLanguage array

When using ArrayAdd:
  • the array is automatically enlarged to receive the new element.
  • the element is converted (if necessary) into the type of the other array elements.
Note: When declaring an array of N by M elements, this array contains N empty elements. For example, the array declared below contains 3 empty strings.
MyArray is array of 3 strings
When adding an element (ArrayAdd), this element is automatically added after the elements already found in the array.
In our example, the added element will correspond to the 4th element.

Adding an element into an advanced array property

When using ArrayAdd:
  • 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.

Adding an element into a list

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

Adding an array into an array (concatenation)

When using ArrayAdd:
  • the array is automatically resized to receive the new elements. The elements of <WLanguage variable to concatenate> are added at the end of <WLanguage variable>.
  • the two arrays must have the same type.
  • the arrays must have the same dimension.
  • the array dimensions (other than the first dimension) must be identical.
    For example:
    Correct code:
    t1 is array of * by 2 int = [[1,2],[3,4]]
    t2 is array of * by 2 int = [[5,6],[7,8],[9,10]]
    Add(t1, t2)
     
    Incorrect code:
    t1 is array of * by 3 int = [[1,2],[3,4]]
    t2 is array of * by 2 int = [[5,6],[7,8],[9,10]]
    Add(t1, t2)
     

Adding a list into a list (concatenation)

When using ArrayAdd:
  • the list is automatically enlarged to receive the new elements. The elements of <WLanguage variable to concatenate> are added at the end of <WLanguage variable>.
  • the two lists must have the same type.

Adding the content of a structure into an array of structures without using a variable of this structure

If you are using an array of structures with few members, it may be easier to directly add a structure by using the [ ] operator (square brackets). For example, for the following structure:
// Structure to store a letter and its ASCII code
STKey is Structure
sKey is string
nAsciiCode is int
END
// Array of structures
arrKeys is array of STKey
In most cases, the addition is performed by using a variable of structure type:
// Temporary structure for the addition
stAKey is STKey
// Stores the letter A
stAKey.sKey = "A"
stAKey.nAsciiCode = Asc("A")
ArrayAdd(arrKeys, stAKey)
With the [ ] operator, you get better legibility:
// Stores the letter A
ArrayAdd(arrKeys, stAKey) ["A", Asc("A")])

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 ArrayAdd.
This function cannot be used on:
  • non-created arrays.
  • fixed arrays.

Miscellaneous

Component : wd240vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment