Dim Pos = 0 , Pos1 = 0, LastPos = 0 As Int
Dim S As String = $"Hello, there. "How are you doing, there?""$
Dim Result As List
Result.Initialize
'Make sure there are no double spaces.
Do While S.Contains(" ")
S = S.Replace(" "," ")
Loop
Pos = S.IndexOf2(" ",LastPos)
Do While Pos > -1
If S.CharAt(Pos + 1) = QUOTE Then
Result.Add(S.SubString2(LastPos,Pos))
Pos1 = S.IndexOf2(QUOTE,Pos + 2)
If Pos1 = -1 Then
Result.Add(S.SubString(Pos + 1))
LastPos = S.Length
Log("Error: Closing quote not found")
Else
Result.Add(S.SubString2(Pos + 2, Pos1))
LastPos = Pos1 + 1
End If
Else
Result.Add(S.SubString2(LastPos,Pos))
LastPos = Pos + 1
End If
Pos = S.IndexOf2(" ",LastPos)
Loop
For Each S As String In Result
Log(S)
Next
Log("Done")