; ID: 958 ; Author: Noel - Banned ; Date: 2004-03-04 01:16:40 ; Title: Tokenize ; Description: A function to split strings into smaller pieces by specifying seperators. ;;;;;;;;EXAMPLE;;;;;;;;;; Graphics 320,240,32,2 SetBuffer(FrontBuffer()) St$ = "This is a string that will be cut into bits and pieces" Tokenize St$,"( )"+Chr(10) For T.Token = Each Token Write T\T+" " Next Delete Each Token Waitkey ;;;;;;;;CODE ;;;;;;;;;;; Type Token Field T$ End Type Function Tokenize(S$,Symbols$=", ()") Local Closest=Len(S$) While Not S$ = "" S$ = Replace(Trim(S$)," "," ") If Not Left(S$,2) = "//" Then For X = 1 To Len(Symbols$)-1 Current=Instr(S$,Mid(Symbols,X,1)) If Current < Closest And Current > 0 Then: Closest = Current: EndIf Next Else Exit EndIf T.Token = New Token T\T$ = Trim(Mid(S$,1,Closest)) S$ = Replace(Trim(Right(S$,Len(S$)-Len(T\T$)))," "," ") Closest=Len(S$) Current=Closest+1 Wend Return True End Function