Quick challenge (who's is the fastest)

Miscellaneous Forums/General Discussion/Quick challenge (who's is the fastest)

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Type textlist

Field value$
Field index
End Type 

Function ParseTextIncludingSeparator(stringvalue$,separator$)
startchar=1
For i=1 To Len(stringvalue$)
If Mid(stringvalue,i,1)=separator Or i=Len(stringvalue) Then 
bitoftext.textlist=New textlist
bitoftext\index=startchar
bitoftext\value=Mid(stringvalue,startchar,1+i-startchar)
startchar=i+1
EndIf 

Next
End Function


Function ParseTextNotIncludingSeparator(stringvalue$,separator$)
startchar=1
For i=1 To Len(stringvalue$)
If Mid(stringvalue,i,1)=separator Or i=Len(stringvalue) Then 
bitoftext.textlist=New textlist
bitoftext\index=startchar
If Mid(stringvalue,i,1)=separator Then bitoftext\value=Mid(stringvalue,startchar,i-startchar) Else bitoftext\value=Mid(Stringvalue,startchar,1+i-startchar)
startchar=i+1
EndIf 

Next
End Function

Graphics 800,600,32,2
;example
ParseTextIncludingSeparator("Hello jim, How, have you , been?",",")
i=0
For bitoftext.textlist=Each textlist
Text 0,i,"Index:"+bitoftext\index+", Text:"+bitoftext\value
i=i+15
Next
Delete Each textlist
ParseTextNotIncludingSeparator("Hello jim, How, have you , been?",",")
For bitoftext.textlist=Each textlist
Text 0,i,"Index:"+bitoftext\index+", Text:"+bitoftext\value
i=i+15
Next

Flip
WaitKey
End


EDIT - (5 minutes later) - I think I misunderstood what you were after...