It is currently Sun Mar 07, 2021 11:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: StringField better
PostPosted: Wed Dec 22, 2004 11:37 am 
Offline
New User
New User

Joined: Tue Dec 21, 2004 5:26 pm
Posts: 3
Location: Brazil - Parana
Code updated For 5.20+

it's code i am use all time...


Code:
Procedure.s stringfield2(var$,indice,p$)
lp=Len(p$)
bak=1
Repeat
  x=FindString(var$+p$,p$,bak+1)
  If x
    c+1
    If c=indice
      ProcedureReturn Mid(var$,bak,x-(bak))
    EndIf
    bak=x+lp
  EndIf       
Until x=0
EndProcedure


;thanks dom


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 22, 2004 2:49 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Mon Jun 02, 2003 1:42 am
Posts: 2010
Location: Ashland, KY
It is early and I haven't had my coffee yet but I don't see any benefit over the built in StringField() function?

_________________
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net


Top
 Profile  
Reply with quote  
 Post subject: STRINGFIELD BETTER
PostPosted: Thu Dec 23, 2004 12:00 am 
Offline
New User
New User

Joined: Tue Dec 21, 2004 5:26 pm
Posts: 3
Location: Brazil - Parana
Karbon wrote:
It is early and I haven't had my coffee yet but I don't see any benefit over the built in StringField() function?


HI Karbon

TRY IS CODE, change idea.

thanks dom....
sorry my english...


Code:
Procedure.s stringfield2(var$,indice,p$)
lp=Len(p$)
bak=1
Repeat
  x=FindString(var$+p$,p$,bak+1)
  If x
    c+1
    If c=indice
      ProcedureReturn Mid(var$,bak,x-(bak))
    EndIf
    bak=x+lp
  EndIf       
Until x=0
EndProcedure


a$="123456789stop123456789stoppurebasicstopisstopcool"

;using STRINGFIELD NORMAL
Debug StringField(a$,1,"stop")
Debug StringField(a$,2,"stop")
Debug StringField(a$,3,"stop")
Debug StringField(a$,4,"stop")
Debug StringField(a$,5,"stop")
Debug StringField(a$,6,"stop")
Debug StringField(a$,7,"stop")
Debug StringField(a$,8,"stop")
Debug StringField(a$,9,"stop")


;using STRINGFIELD2 MODIFIED
Debug StringField2(a$,1,"stop")
Debug StringField2(a$,2,"stop")
Debug StringField2(a$,3,"stop")
Debug StringField2(a$,4,"stop")
Debug StringField2(a$,5,"stop")
Debug StringField2(a$,6,"stop")
Debug StringField2(a$,7,"stop")
Debug StringField2(a$,8,"stop")
Debug StringField2(a$,9,"stop")


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2004 2:57 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Apr 25, 2003 11:08 pm
Posts: 469
dom,

What you've found is that PureBasic's StringField() function can only accept a delimiter of ONE character. Your function removes this restriction, and is handy with delimiters like "stop".

Regards,
Eric


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye