ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Queue, stack, list and array functions / Array functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
StringToArray (Function)
In french: ChaîneVersTableau
Fills a one- or two-dimensional array of the specified type with the character string passed as parameter. The array is cleared before it is filled.
Example
// One-dimensional array
sMyValues is string = "AT" + CR + "B" + CR + "C" + CR + "D" + CR + "D"
// Initial array
MyArray is array of 3 strings
StringToArray(sMyValues, MyArray)
// The array contains: "A" , "B" , "C" , "D" , "D"
// One-dimensional array
sString is string = "A" + CR + "B" + ";" + "C" + CR + "D" + "," + E + CR + "F"
// Initial array
MyArray is array of 6 strings
StringToArray(sString, MyArray, [CR, ";", ","])
// The array contains: "A" , "B" , "C" , "D" , "E" , "F"
// Two-dimensional array
sMyValues is string = "AT" + TAB + "B" + CR + "C" +TAB + "D" + CR + "E" + TAB + "F"
// Initial array
MyArray is array of 2 by 3 strings
StringToArray(sMyValues, MyArray)
// The array contains: "A;B" , "C;D" , "E;F"
// Two-dimensional array
sString is string = "A" + TAB + "B" + CR + "C" + "/" + "D" + "*" + E + "\" + "F"
// Initial array    
MyArray is array of 2 by 3 strings
StringToArray(sString, MyArray, [CR, "*"], [TAB, "/", "\"])
// The array contains: "A;B" , "C;D" , "E;F"
Syntax

One-dimensional array Hide the details

StringToArray(<String> , <Array name> [, <Element separator>])
<String>: Character string
Contains the different array elements. The string will be cut according to the specified element separator.
If this parameter corresponds to an empty string (""), the dimension of the array is set to one dimension and a single row.
<Array name>: Array variable
Name of the one-dimensional array into which the elements found in the string must be added. This array must be allocated in a simple type or in a structure type.
<Element separator>: Optional string or Array
Separator used in <String> to separate the values of the different array elements. This separator can be:
  • a string (e.g.: ";").
  • an array of strings (e.g.: [CR,";"]).
    Java Not available.
The element separator used by default is the CR character (Carriage Return).

Two-dimensional array Hide the details

StringToArray(<String> , <Array name> [, <Row separator> [, <Column separator>]])
<String>: Character string
Contains the different array elements.
The string will be cut according to the specified row separator, then according to the column separator. The elements will be added row by row.
  • There will be as many rows as the number of <Row separator>.
  • Columns will be added if the maximum number of <Column separator> exceeds the number of columns in the array.
  • Each column must have a corresponding value for the row.
  • The number of result array columns is the number of elements in the first row.
  • If a row contains more elements than the first row, the extra elements will be concatenated in the last element.
  • If a row contains less elements than the first row, the non-assigned array cells keep their default value.
  • If this parameter corresponds to an empty string (""), the dimension of the array is set to one dimension and a single row.
<Array name>: Array variable
Name of the two-dimensional array where the elements found in the string must be added. This array must be allocated in a simple type or in a structure type.
<Row separator>: Optional string or Array
Separator used in <String> to separate the values of the different rows. This separator can be:
  • a string (e.g.: ";").
  • an array of strings (e.g.: [CR,"*"]).
    Java Not available.
The row separator used by default is the CR character (Carriage Return).
<Column separator>: Optional string or Array
Separator used in the <String> to separate the values of the different columns. This separator can be:
  • a string (e.g.: "TAB").
  • an array of strings (e.g.: ["/", "\"]).
    Java Not available.
The column separator used by default is TAB.
Remarks
  • The dimension of the array will be modified if necessary: rows and columns may be added according to the values found in <String>.
  • The structure arrays supported are the one-dimensional arrays only.
  • The arrays containing UNICODE strings or variants are not supported.
  • For the Duration type, the value must be given in thousands of a second. The value 0 is not valid. You must use "0000000000".
Business / UI classification: Neutral code
Component: wd290vm.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Example
ArrPaises is array of strings

ListaPaisesTxt is string = [
França
Brasil
Estados Unidos
]

StringToArray(ListaPaisesTxt, ArrPaises , CR)

//C'est magnifique !!!!!
BOLLER
15 Feb. 2020

Last update: 07/03/2023

Send a report | Local help