Scripting > UNICOM Intelligence Function Library > Text functions > Split
 
Split
Returns an array that contains substrings.
Syntax
Split(Val [, Delimiter [, Count ]])
Parameters
Val
Type: Text
Text value to split. See also Specifying text strings as arguments.
Delimiter
Type: Text
Optional. Delimiter between substrings. The default is a single space.
Count
Type: Long
Optional. The maximum number of substrings to return. If omitted or less than zero, all substrings are returned.
(return)
Type: Categorical
An array containing the substrings from Val.
Remarks
This function is useful when you are parsing text strings that contain a number of substrings separated by a character such as a comma (,). For example, the lines of an address are often separated by a comma.
If Val is an empty string, the return value is an empty array. Otherwise, if Delimiter is an empty string or is not found in Val, the return value is an array containing one item, a copy of Val. If the current data value is NULL, Val is an empty string and the return value is an empty array.
Note The Split function returns a categorical value, making it impossible to assign elements of the returned array. It should also be noted that the result from the Split function is not a real categorical value, because the elements of a categorical must be of type Long (int - VT_I4), not text. The parser treats the value as a categorical, but an error is returned when attempting to pass the value into a function that expects a real categorical (ContainsAny for example).
Example
This mrScriptBasic example uses the Split function to return the first line and the first two lines of an address that is stored in a single variable with the lines separated by commas. It also shows an example of using the function using the default parameters:
Dim Address, FirstLine, FirstTwoLines, Defaults
Address = "363 Park Road, Ashford, Kent"
FirstLine = Address.Split(",", 1) ' Returns {363 Park Road}
FirstTwoLines = Address.Split(",", 2) ' Returns {363 Park Road, Ashford}
Defaults = Address.Split() ' Returns {363,Park,Road,,Ashford,,Kent}
See also
AscW
Text functions