Quick challenge (who's is the fastest)

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Off the top of my head:

[edit]
Heres my function after converting frmo Visual Basic, without BB.

Function Gettextsection(inp$,sep$,index)
local last = 1,cnt,ins,out$,olast
repeat
	ins = InStr(inp$, sep$,last)
	If ins = 0 Then ins = Len(inp$)
	If ins > 0 Then olast=last: Cnt = Cnt + 1: last = ins + 1
Until ins = 0 Or Cnt = index or index=0
If olast>0 then out$ = Mid$(inp$, olast, ins - olast)
Return Out$
End Function




Heres the function as I originally wrote it, Still untested
Function index(inp$,tok$,getindex)
local Lastpos=1
local curcount=0
local ins
local out$

repeat
 ins=instr(inp$,tok$,lastpos)
 if ins>0 then out$=mid$(inp$,lastpos,ins):lastpos=ins+1:curcount=curcount+1 ;Thanks Grey Alien!!!! :P :P :P
until curcount=index or ins=0

if curcount=getindex then return Out$
end function



Not sure if that will do what you need, but I knocked it up without documents or anything, so it will likely have a couple of bugs.