Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Token fbc routines by Tim Keal & Mysoft
- declare function token overload (subject as string,sep() as string,index as string="1") as string
- declare function token(subject as string,sep as string=",",index as string="1") as string
- function token overload (subject as string,sep() as string,index as string="1") as string
- dim as string buffer,Ln
- dim as long o,t,i
- dim as long s(lbound(sep,1) to ubound(sep,1))
- buffer=subject
- t=0
- i=val(index)
- if val(index)>0 then
- do
- t=t+1
- for n=lbound(sep,1) to ubound(sep,1)
- s(n)=instr(1,buffer,sep(n))
- Ln=mid(buffer,o+len(sep(n)))
- buffer=mid(buffer,o+len(sep(n)))
- next n
- for n=lbound(sep,1) to ubound(sep,1)
- if s(n)<o then
- o=s(n)
- d=n
- end if
- next n
- Ln=mid(buffer,o+len(sep(d)))
- buffer=mid(buffer,o+len(sep(d)))
- loop until t=val(index)
- token=Ln
- elseif index="ct" then
- do
- t=t+1
- for n=lbound(sep,1) to ubound(sep,1)
- s(n)=instr(1,buffer,sep(n))
- next n
- for n=lbound(sep,1) to ubound(sep,1)
- if s(n)<o then
- o=s(n)
- d=n
- end if
- next n
- Ln=mid(buffer,o+len(s(d)))
- buffer=mid(buffer,o+len(s(d)))
- loop until o=0
- token=str(t)
- end if
- end function
- function token(subject as string,sep as string=",",index as string="1") as string
- dim as string sTemp(0) : sTemp(0) = sep
- return token(subject,sTemp(),index)
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement