Page 2 of 4

Re: Double-quotes in strings

Posted: Mon Mar 04, 2013 11:25 pm
by rsts
@Thade +1

:)

Re: Double-quotes in strings

Posted: Mon Mar 04, 2013 11:43 pm
by skywalk
Danilo wrote:
IdeasVacuum wrote:
We all know we can use DQUOTE$
I didn't know that! :shock:
I added this constants to PB, round about 9 or 10 years ago. It is my fault I didn't add the short #DQ$ too. Sorry skywalk for being so stupid! :D
Ha, not stupid, just overworked. :wink:
Really should add #DQ$ now.
Wow, did I hate """'&'""" in VB6...Talk about eye strain :evil:

Re: Double-quotes in strings

Posted: Mon Mar 04, 2013 11:51 pm
by Kiffi

Code: Select all

myString.s = "He said ''hello'' to her"
Debug ReplaceString(myString, "''", Chr(34)) ; Outputs -> He said "hello" to her
so easy... ;-)

Greetings ... Kiffi

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 4:10 am
by Tenaja
MachineCode wrote:I didn't realise it would ruin database queries, so I guess it's not such a good idea after all.....
It all depends if you want to cater to "database programs" or "everything except database programs."

Personally, I'd much rather have the new feature, and I can always use the #SingleQuote$ for the db queries.

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 8:51 am
by MachineCode
Yes, Kiffi, but it adds overhead and time (no matter how small). A compiler replacement would treat it like a constant, with zero overhead. But as pointed out, I didn't realise it would affect database strings, so I'm happy to drop the suggestion. I don't use databases so they never occurred to me.

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 10:33 am
by Danilo
Again, the general idea is good. That's why we discuss it here. It is just not as easy to pick some random characters you like ('' or $$ or %%)
and use this now as auto replacement for double quotes. As we have seen here, it breaks other things.
You think it looks ugly, but technically the VB way is the best. You can't use " within strings now, as it ends the string. You can
use all other printable characters within strings, but not ". So adding VB-like support is the shortest solution to write, and also very easy to implement.
" starts a string. Now scan for next occurrence of ". If next character is again ", replace both with chr(34) and continue scanning for next ",
otherwise it was the string end. Easy to add to parser/compiler and to IDE for syntax highlighting. And common to guys coming from other BASIC languages.

Additionally add #DQ$ to residents, so traditional #DOUBLEQUOTE$, #DQUOTE$ and Chr(34) can be written even shorter.

It is also 100% backward compatible.

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 11:17 am
by Mohawk70
Danilo wrote:In my opinion PB should not replace anything within my strings automatically. So using the double quote character itself (like VB) would be the only valid option, because it is the only printable character that can't be used in strings directly.
Not too mention that this would have the possibility to wreak havoc with encrypted data embedded into code :!:

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 12:23 pm
by PMV
Danilo wrote:It is also 100% backward compatible.
sure?

Code: Select all

text.s = "I'm a " + string + ", but a variable or a constant?"
As i see the example VB expects double double quotes.

Code: Select all

text.s = "I'm a ""string"" and just constant!"
text.s = "I'm a " + string + " and a variable!"
It seems handy, but i would like to have the possibility to interchange it with single quotes.

Code: Select all

text.s = "I'm a string" + ' created with "single" and "double" quotes.'
MFG PMV

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 12:27 pm
by Danilo
PMV wrote:
Danilo wrote:It is also 100% backward compatible.
sure?
Yes, absolutely.
PMV wrote:As i see the example VB expects double double quotes.

Code: Select all

text.s = "I'm a ""string"" and just constant!"
text.s = "I'm a " + string + " and a variable!"
It seems handy, but i would like to have the possibility to interchange it with single quotes.

Code: Select all

text.s = "I'm a string" + ' created with "single" and "double" quotes.'
Not possible. It's just a mess of characters. For example, ' is used for character constants already, like 'a' in a Case switch.

It is one of the problems in this forum: Ordinary People without any qualification and without deeper thinking
make suggestions and think they are right, where they don't know anything about the specific topic.
To make suggestions to the internals of a compiler, you should have studied compiler and programming languages design,
and at least have written one or two compilers. Problem here is, everybody who knows nothing and everybody who has
not a deeper understanding of a specific topic, can make suggestions that make no sense.

I don't know yet how we can handle this problem. It is meeting absolute beginners with experts that studied a topic for years.
Beginners make non-sense requests all the time, and experts in the field give answers. Beginners don't believe what the experts say.
It can be very annoying from time to time, and experts usually don't want to spend their time answering beginner's questions
and explain everything, as they have other things to do.

Maybe any suggestions to THAT problem?

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:14 pm
by PMV
Was that really necessary, please think twice before posting after
your bier! Are you really drunk at this time? Or just mad of some
one in reallife? I don't know why, but please ... it is a discussion ...
it is not more stupid then every other post here, including yours.
Especially, why do have customers have to study a specific
topic before they are allowed to make wishes that someone else
needs to handle? lol! No one would be allowed to make wishes
anywhere.

And even so i have forgotten about the character-use, it is still
not unpossible and up to fred who makes the final decision. :wink:
We just discuss it in public.

MFG PMV

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:32 pm
by rsts
Actually I thought it was a good explanation of why we don't get feedback to all the feature requests.

Finally, someone telling it like it is. :)

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:33 pm
by MachineCode
Danilo wrote:" starts a string. Now scan for next occurrence of ". If next character is again ", replace both with chr(34) and continue scanning for next ",
otherwise it was the string end. Easy to add to parser/compiler and to IDE for syntax highlighting. And common to guys coming from other BASIC languages.
+1 :)

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:36 pm
by Danilo
PMV wrote:Was that really necessary, please think twice before posting
Yes, it is absolutely necessary to discuss this topic. It is a real world situation here.
Experts meeting beginners, and beginners don't believe what experts in a field say.
Experts justify everything, they explain what is better and why it is better. Beginners
just wish things, without a deeper understanding. You understand Darwin's evolution theory,
but you never ever read Darwin's books? It is the same for compiler stuff. Did you read
80 books about compiler design? No? You can still make any request, but some things
just can't work as you dreamed it! For some advanced things you just need a deeper understanding
of that specific topic. You don't have a clue of politics, but you always know what is
the right thing to do in politics. It is one problem of our time, that everybody thinks
he knows everything! In this case, I really recommend reading Darwin, where he compares
man with other animals. It is at least a start for deeper understanding.

BTW, Darwin's books are available for free on Kindle (for Kindle, PC, Mac, ...) ;)

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:49 pm
by PMV
Danilo wrote:
PMV wrote:Was that really necessary, please think twice before posting
Yes, it is absolutely necessary to discuss this topic. It is a real world situation here.
Experts meeting beginners, and beginners don't believe what experts in a field say.
Experts justify everything, they explain what is better and why it is better. Beginners
just wish things, without a deeper understanding. You understand Darwin's evolution theory,
but you never ever read Darwin's books? It is the same for compiler stuff. Did you read
80 books about compiler design? No? You can still make any request, but some things
just can't work as you dreamed it! For some advanced things you just need a deeper understanding
of that specific topic. You don't have a clue of politics, but you always know what is
the right thing to do in politics. It is one problem of our time, that everybody thinks
he knows everything! In this case, I really recommend reading Darwin, where he compares
man with other animals. It is at least a start for deeper understanding.

BTW, Darwin's books are available for free on Kindle. ;)
I'm not part of the problem. I always think of "do i have
undstand it right?" ... but i'm a human. Believe it or not,
you too. You make mistakes as i did. If you would be that
good, you have seen on your own, that i have just miss read
your post. As you can see, i have written the same thing after
saying, "are you sure?" by writing "VB wants double double qoutes".

Do you have to study communication now? :mrgreen:

Re: Double-quotes in strings

Posted: Tue Mar 05, 2013 1:56 pm
by rsts
PMV wrote: If you would be that
good, you have seen on your own, that i have just miss read
your post.
People who expect other people to read their mind, should probably not be posting at all. ;)