SplitString to list or array with option double-quotes (CSV)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: SplitString to list or array with option double-quotes (CSV)

Post by Tenaja »

ChrisR wrote: Thu Nov 10, 2022 10:32 pm I get it, no worries and sorry for the inconvenience, i don't want to spam your thread. I don't understand in a first reading why you use (Just get it, to get around the PB syntax):

Code: Select all

text.s = "0;1x;2xx;'Text with separator (;)';4xxxx;5xxxxx;'Text with linefeed " + #LF$ + "and separator (;)';End"
text = ReplaceString(text, "'", #DQUOTE$)
I can't speak for the original author, but this technique can come in handy to build a string containing double quotes, while keeping it readable in a way that pb doesn't allow. Otherwise, in PB, to include a double quote, you have to use the + #DQUOTE$ + symbol set throughout, and readability is killed.
User avatar
mk-soft
Always Here
Always Here
Posts: 6205
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SplitString to list or array with option double-quotes (CSV)

Post by mk-soft »

I could also have written it as a literal string. But it was relatively new at the time.

Code: Select all

text.s = ~"0;1x;2xx;\"Text with separator (;)\";4xxxx;5xxxxx;\"Text with linefeed\nand separator (;)\";End"
But I don't find it any more readable. The first and last dquote should have a different colour.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply