Requires: gfawinx.lg32
Separates a delimited string into a string array
StrToArr in, sep, ar()
in, sep | : string expression or variable |
: string array |
StrToArr splits a string - in - into an array of substrings at the positions defined by the sep character. StrToArr works much like the Array command that splits a string on the LF (ascii 10) character except that StrToArr splits the string using a user-defined character.
$Library "gfawinx"
Dim ButtonText$ = "Button 1|Button 2|Button 3"
Dim aBtn() As String
Dim ct As Int32
StrToArr ButtonText$, "|", aBtn()
Debug.Show
While ct < Dim?(aBtn())
Debug ct,aBtn(ct)
Inc ct
Wend
StrToArr replaces all occurrences of the sep character with a LF (#10) and then passes the string to the Array= command.
StrToArr is implemented as a Sub which takes implicit by reference parameters. Literal strings are copied to a hidden local string variable before they are passed to the procedure, string variables are not copied but passed by reference.
{Created by Sjouke Hamstra; Last updated: 11/08/2019 by James Gaite}