Double-quotes in strings

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Double-quotes in strings

Post by Danilo »

PMV wrote:Do you have to study communication now? :mrgreen:
That's possible! I try to communicate with ordinary humans all day. There are misunderstandings all time,
and this is the reason I try to explain everything word by word. Does it mean I am an alien, coming
from future? For me, it is just normal to re-think everything, to think about every possible outcome and
every possible situation. It is me! Other people seem to think only about themselfs, and what happens
within the next seconds. Don't know, but ordinary people are somewhat boring to me, not archiving anything
and not wanting anything in life... so to be different is not so bad at the end. ;)
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Double-quotes in strings

Post by PMV »

Danilo wrote:For me, it is just normal to re-think everything, to think about every possible outcome and
every possible situation. It is me!
I do that, too. Can't say if i do that less then you or more,
but who cares? More important is that we are all humans.
Some are more stupid then others, but everything has there
advantages and disadvantages. Speaking with someone who
has another opinion is sometimes the best way to find a
fresh solution. And it doesn't count how much that one
knows about a specific topic. Especially if you doesn't have
any clue about how much that one really knows. Just
thinking "he has to not know anything" is a bad characteristic :wink:
and an ordinary one, too *grins*

MFG PMV
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Double-quotes in strings

Post by Kukulkan »

+1 for the ""special"" VB6 notation.

I still would love to have PHP style escape characters but I agree with Danilo that this is not that easy in PB environment as the single quotes having special meaning with characters. So the VB6 style is ok for me and this would be very helpful indeed.

Kukulkan
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Double-quotes in strings

Post by luis »

Wow... I certainly see something very ordinary here.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Double-quotes in strings

Post by Demivec »

+1 for the ""special"" VB6 notation.

I am familiar with this notation from the use of ancient BASIC's that had limitations on line length (120 characters). It works well enough to shorten a line instead of using one of the constant notations: +Chr(34)+; +#DQUOTE$+; or +#DQ$+, which add 9, 10, or 6 characters instead of 1 for the solitary double quote. You then realize that they are usually used in pairs +/- a concatenation character, and you get 18, 20, 12, or 2 characters that are required to place a set of double quotes in a string in this manner.

Apart from the savings achieved by using less characters, which in this day and age only refers to convenience and nothing more, I don't see this as a must-have feature. However, even though I would use whatever notation was necessary to place the quotes in the string I would switch immediately to using this if it became available. :)

I think beginners would find it easy to use as well. They also would have the choice of which they preferred to use, according to their comprehension, and would choose what works well for them.

@Danillo: [Off Topic] It is important to be able to discuss things freely without a pre-requirement that you know anything; that is one of the few things that allows beginners to become experts. The discussion becomes useless when someone thinks that only their opinion is right and then tries to defend it by eliminating those that disagree with them from the discussion. As an expert you may have had discussions with experts where you were considered a beginner, where they could only roll their eyes because you did not know as much as they did; they may also have just been more patient while your understanding matured. Darwin said 'survival of the fittest' and not 'survival of the only'. :) [/Off Topic]
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Double-quotes in strings

Post by Danilo »

Demivec wrote:@Danillo: [Off Topic] It is important to be able to discuss things freely without a pre-requirement that you know anything; that is one of the few things that allows beginners to become experts. The discussion becomes useless when someone thinks that only their opinion is right and then tries to defend it by eliminating those that disagree with them from the discussion. As an expert you may have had discussions with experts where you were considered a beginner, where they could only roll their eyes because you did not know as much as they did; they may also have just been more patient while your understanding matured. Darwin said 'survival of the fittest' and not 'survival of the only'. :) [/Off Topic]
PMV and me had a little argument last weekend. It is the reason I thought he wanted to play games with me yesterday, making jokes.
Before PMV's message I answered kindly, I think (Posting "Again, the general idea is good."). After PMV's first posting you see a change
in my postings. I don't blame PMV - I am the problem here.
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Double-quotes in strings

Post by Didelphodon »

+1 for the ""-version
Go, tell it on the mountains.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: Double-quotes in strings

Post by Rescator »

I was gonna post here but I split this off instead http://www.purebasic.fr/english/viewtop ... =3&t=53840
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Double-quotes in strings

Post by davido »

A alternative would be to have a choice of string delimiters such as " ' !

Delimiter$ = !He said: 'She said: "Pure Basic is a great programming language even with a single string delimiter?" if I recall correctly.'!
DE AA EB
VoSs2o0o
User
User
Posts: 24
Joined: Fri Aug 06, 2010 11:46 pm

Re: Double-quotes in strings

Post by VoSs2o0o »

+1 for the ""-version
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Double-quotes in strings

Post by RichAlgeni »

How about an additional string delimiter, such as the pipe character? For instance:

Code: Select all

newString.s = |This is a string|
Now pipe may not be the best character to use, a different character may be better, but this method would make it easier to use double quotes inside a string.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Double-quotes in strings

Post by BorisTheOld »

The defacto standard for many years, in many different languages, has been to use "" to represent a doublequote within a string.

Using other non-tranditional characters, such as two single quotes, or ! , would break a lot of existing code. Even the \n type of escape sequences are probably not a good idea, since they have not been a feature of PB literal strings and could break code.

We do a lot of text manipulation when generating our source code. Except for the "" usage, all the other suggestions would break our code in a big way. We have mega-bytes of code templates full of unusual character sequences, so the last thing we need is for PB to be substituting "random" characters in quoted strings. That would not make me happy a happy programmer.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Double-quotes in strings

Post by RichAlgeni »

BorisTheOld wrote:the last thing we need is for PB to be substituting "random" characters in quoted strings. That would not make me happy a happy programmer.
Boris is apparently a 'glass is half empty' kind of guy. Obviously this wouldn't be a 'random' character, it would need to be defined in someway, so that the compiler knew what it was. I've seen much less sophisticated compilers handle this correctly.

Under this scenario, anything within two of these new delimiters will be considered a string. It would take just a little thought and some intelligent design to utilize correctly. And maybe a glass that is at least half full.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Double-quotes in strings

Post by ts-soft »

I would love escape-sequences with \ and compilerdirectives to enable and disable like:
EnableEscape
DisableEscape
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
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Double-quotes in strings

Post by Tenaja »

ts-soft wrote:I would love escape-sequences with \ and compilerdirectives to enable and disable like:
EnableEscape
DisableEscape
And for those who prefer "random" characters...

EnableEscape "/" ; makes the escape character /
EnableEscape "|" ; makes the escape character |
Post Reply