SPLIT
SPLIT s, delim, byref words [, pairs] [USE expr]
Splits the string s at the position of the given
delimiters delim and returns an array words
with the splitted substrings. The optional parameter pairs
can be used to group words. The optional Use expr is
applied to every splitted substring. If delim contains more
than one character, each character representing a delimiter.
See SINPUT for an alternative command to split a string.
Example 1: Split a string using two delimiters
s = "/etc/temp/filename.ext"
SPLIT s, "/.", v ' Splits the string using the delimiters "/" and "."
FOR i = 0 TO UBOUND(v)
PRINT i; " ["; v(i); "]"
NEXT
' Output:
' 0 []
' 1 [etc]
' 2 [temp]
' 3 [filename]
' 4 [ext]Example 2 : Using the argument “pairs”
s = "/etc/temp/filename.ext"
SPLIT s, "/", v, "temp"
FOR i = 0 TO UBOUND(v)
PRINT i;" [";v(i);"]"
NEXT
' Display
0 []
1 [etc/temp]
2 [filename.ext]Example 3: Using “USE expr”
s = "/etc/temp/filename1.ext " ' additional spaces at the end of the string
SPLIT s, "/", v, "temp" USE TRIM(x) ' trim(x) will remove spaces at the beginning
' and the end of the splitted strings;
' try the example without "USE TRIM(x)"
FOR i = 0 TO UBOUND(v)
PRINT i;" [";v(i);"]"
NEXT
' displays
' 0 []
' 1 [etc/temp]
' 2 [filename1.ext]Code samples using SPLIT
blackjack.bas
BlackJack.bas
Calendar.bas
calendar.bas
coordplot.bas
CSV_Viewer.bas
gputmalc.bas
gui_cal.bas
irc-bot.bas
memory match game.bas
palm_cli.bas
palmcli.bas
pdocview.bas
radish.bas
scambling text.bas
scampling.bas
subversion.bas
TinyBASIC.bas
tracklog.bas
Weekday.bas
weekday.bas
zacalc.bas