split | |||||||||||||
Type | command | ||||||||||||
Dictionary | LCS | ||||||||||||
Library | LiveCode Script | ||||||||||||
Syntax |
| ||||||||||||
Summary | Transforms a list into an array. | ||||||||||||
Introduced | 1.1 | ||||||||||||
Changes | Starting with LiveCode 7.0, you can pass a string of characters as a column and row delimiter (it is no longer restricted to a single character). Starting with LiveCode 8.0, you can split by empty delimiters, which are treated as never appearing in the input string. | ||||||||||||
OS | mac, windows, linux, ios, android, web | ||||||||||||
Platforms | desktop, server, mobile | ||||||||||||
Parameters |
| ||||||||||||
Example |
| ||||||||||||
Related | Keyword: [], using Property: columnDelimiter, rowDelimiter Constant: return, space Command: combine, intersect, union Function: extents, keys Glossary: array, element, key | ||||||||||||
Description | Use the split command to place a list in an array so you can easily address each part of the list. The split command separates the parts of the variable into elements of an array. After the command is finished executing, the variable specified is an array. If the first form of the split command is used, the parts that become elements are defined by the primaryDelimiter. For example, if the primaryDelimiter is return, each line of the variable becomes an element in the resulting array. If you don't specify a secondaryDelimiter, then a simple numeric array is created, with each key being a number, starting with 1. If you specify a secondaryDelimiter, the key for each element is the first portion of each part of the variable, separated from the element's content by the secondaryDelimiter. For example, if the primaryDelimiter is return and the secondaryDelimiter is space, the remainder of each line of the variable is placed in an array element whose key is the first word of the line. If you use the For example, the following statements create an array:
If the second form of the split command is used, the string is split into elements of an array where each element using the rowDelimiter or columnDelimiter, where each element of the resulting array is a row or column of the string respectively. Splitting a string by row converts the string into an array where each element of the array corresponds to a row in the string separated by the rowDelimiter. Splitting a string by column converts the string into an array where each element of the array corresponds to a column in the string separated by the columnDelimiter. | ||||||||||||
Tags | arrays |