Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function token(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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement