Extract the first and second word from a string
The script extracts the first word and the second word from a long string where words are separated by spaces ; it can be used for any separator (; - . etc....).
You can find the corresponding script file under Script_Examples, sub-directory of scripts.
'SplitIntoArray WinTask function is used.
'Declare the array
Dim string$(2)
buffer$="John Smith Fitz"
SplitIntoArray(buffer$,string$()," ")
msgbox(string$(0))
msgbox(string$(1))
'Old method when SplitIntoArray function was not available in WinTask
buffer$="John Smith Fitz"
'Find the position of character space (" ") in the string buffer$
pos=instr(buffer$," ")
lg=len(buffer$)
string1$=left$(buffer$,pos-1)
string2$=right$(buffer$,lg-pos)
pos=instr(string2$," ")
lg = len(string2$)
string2$=left$(string2$,pos-1)
string3$=left$(string2$,pos-1)
msgbox(string1$+"\n\"+string2$)