#CRLF$ as StringField delimiter

Just starting out? Need help? Post your questions and find answers here.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

#CRLF$ as StringField delimiter

Post by MachineCode »

I see in the manual that StringField's delimiter can only be one character. But, this works with #CRLF$. Why?

Code: Select all

Debug Len(#CRLF$) ; Returns 2

a$="123"+#CRLF$+"456"+#CRLF$+"789"

For i=1 To CountString(a$,#CRLF$)+1
  Debug StringField(a$,i,#CRLF$)
Next
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: #CRLF$ as StringField delimiter

Post by Shield »

Manual wrote: Delimiter$ The string delimiter to use to separte the fields. It can be a multi-characters delimiter.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: #CRLF$ as StringField delimiter

Post by Danilo »

MachineCode wrote:I see in the manual that StringField's delimiter can only be one character. But, this works with #CRLF$. Why?

Code: Select all

Debug Len(#CRLF$) ; Returns 2

a$="123"+#CRLF$+"456"+#CRLF$+"789"

For i=1 To CountString(a$,#CRLF$)+1
  Debug StringField(a$,i,#CRLF$)
Next
14 February 2013 : Version 5.10
- Added: Multicharacter comparison in StringField()
Syntax

Result$ = StringField(String$, Index, Delimiter$)

Description

Returns the string field at the specified index.

Parameters

String$ The string to parse.
Index The field index to return. The first index is 1.
Delimiter$ The string delimiter to use to separate the fields. It can be a multi-characters delimiter.

Example

Code: Select all

  For k = 1 To 6
    Debug StringField("Hello I am a splitted string", k, " ")
  Next
Supported OS

All
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: #CRLF$ as StringField delimiter

Post by ts-soft »

But it works with PB4.10+ :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: #CRLF$ as StringField delimiter

Post by MachineCode »

ts-soft wrote:But it works with PB4.10+ :wink:
Interesting! But I'm still using 5.00 at the moment, so I never saw the new manual change. :P
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: #CRLF$ as StringField delimiter

Post by ts-soft »

Only tested with your example, so please have attention!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: #CRLF$ as StringField delimiter

Post by Danilo »

ts-soft wrote:But it works with PB4.10+ :wink:
I assume always we talk about latest final, stable versions. If you speak about any older version, it would be helpful to mention it.
Who cares about Version 4.10, it is over 5 years old?

It's considered 'final' and 'stable' if there is no 'beta' in the name. Of course, there will be always new versions, even after 5.11...
Last edited by Danilo on Sat Mar 02, 2013 11:42 pm, edited 2 times in total.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: #CRLF$ as StringField delimiter

Post by MachineCode »

Without looking at the manual (since 5.10 is not installed ATM), does LTrim() and RTrim() support multi-character removal too?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: #CRLF$ as StringField delimiter

Post by Danilo »

MachineCode wrote:Without looking at the manual (since 5.10 is not installed ATM), does LTrim() and RTrim() support multi-character removal too?
LTrim & RTrim v5.10 wrote:'Character$' has to be a one character length string
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: #CRLF$ as StringField delimiter

Post by ts-soft »

Danilo wrote:
ts-soft wrote:But it works with PB4.10+ :wink:
I assume always we talk about latest final, stable versions. If you speak about any older version, it would be helpful to mention it.
Where have you your eyes? PB4.10+ means all Versions, since PB4.10.

MachineCode speaks over <= PB5.00, this can you see, as he mentioned, this is not in the helpfile.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: #CRLF$ as StringField delimiter

Post by Danilo »

ts-soft wrote:MachineCode speaks over PB5.00, this can you see, as he mentioned, this is not in the helpfile.
"Not in the helpfile" means it is not officially supported by version 5.0 he is using. It is like the new 'string.s + i.i' feature - still experimental (means: not working correctly in all cases) and not mentioned in the manual,
not mentioned in the history.
For serious applications and games development you always should rely exactly on the manuals, whether it is PB, MSDN, Apple Developer Central.
Read the text twice and follow it exactly. Other information are not reliable, it is just trial and error. Just works? Good luck with your business!
infratec
Always Here
Always Here
Posts: 7628
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: #CRLF$ as StringField delimiter

Post by infratec »

Hi,

I'm not sure if it works:

#CRLF$ can be detected with the first character #CR
The #LF is not always displayed with Debug.

To test if it works with mutiple charactres you need to test it with something like that:

String: "ABCDEFCDGHIJCDKLMN"
And "CD" as delimiter.

Sorry I can not test it, I removed the old stuff completely :D

Bernd
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: #CRLF$ as StringField delimiter

Post by c4s »

Offtopic:
Danilo wrote:[...] It is like the new 'string.s + i.i' feature - still experimental (means: not working correctly in all cases) and not mentioned in the manual, not mentioned in the history.
Do you mean this feature isn't mentioned? If so, check this out:
PB 5.10 history wrote:- Added: autocast of numeric values when string are involved, allowing to concatenate string and numeric in constants
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: #CRLF$ as StringField delimiter

Post by Danilo »

c4s wrote:Offtopic:
Danilo wrote:[...] It is like the new 'string.s + i.i' feature - still experimental (means: not working correctly in all cases) and not mentioned in the manual, not mentioned in the history.
Do you mean this feature isn't mentioned? If so, check this out:
PB 5.10 history wrote:- Added: autocast of numeric values when string are involved, allowing to concatenate string and numeric in constants
Yes, this is exactly what I meant. It is mentioned in the history in this case (thank you!), ...[removed blah blah]
Last edited by Danilo on Sat Mar 02, 2013 10:03 pm, edited 1 time in total.
User avatar
Michael Vogel
Addict
Addict
Posts: 2812
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: #CRLF$ as StringField delimiter

Post by Michael Vogel »

As seen in the changelog, the CRLF works from version 5.10 on (and LF has been ignored in all PB versions up to version 5.00)

Code: Select all

a$="123"+#CRLF$+"456"+#CRLF$+"789"

For i=1 To CountString(a$,#CRLF$)+1
	s.s=StringField(a$,i,#CRLF$)
	Debug Str(Asc(s))+" / "+Str(Asc(Trim(s,#LF$)))+" : "+s+" / "+Mid(s,2,3<<4)
Next
Post Reply