[BUG?] V2.50 inline double quotes

DTsEMT

Member
Licensed User
Hi!

In the previous version, I defined a string DQ as """, and inserted it in my code like this:

ResultsPage = "<html><body>" & _
"<style Type=" & dq & "text/css" & dq & "media=" & dq & "all" & dq & ">" & _
...

To produce this:

<html><body><style Type="text/css" media="all">
...

Since upgrading to V2.50, I get an error defining string Dq as """, but understand that inline double quotes are now allowed. So updating the code from above now reads:

ResultsPage = "<html><body>" & _
"<style Type="text/css" media="all">" & _

The program fails on compile, telling me "An error occurred. Error parsing program. Error description: Syntax error." I'm then shown the above lines with inline double quotes.

I've tried removing the continuations, no fix. I've tried splitting it differently so that there were no more than two inline double-quotes per line, and that didn't work.

I am probably missing something, but I don't know what. Help please? Thanks!
:eek:
 

kdgarris

Member
Licensed User
You need two double quotes in a row inside of a string in order for it to work, e.g.:

B4X:
Log("Hello, my name is ""Karl""")
 

DTsEMT

Member
Licensed User
Thanks!

You need two double quotes in a row inside of a string in order for it to work, e.g.:

B4X:
Log("Hello, my name is ""Karl""")

Yep, that did it all right! I should probably start paying attention to details...
:sign0104:

Thank you!
 

Vader

Well-Known Member
Licensed User
Why don't you do this:

B4X:
Dim DoubleQuote As String = Chr(34)

Then you could have code such as:

B4X:
Log("Hello " & DoubleQuote & " World" & DoubleQuote)

I believe it makes it easy to read also.
 

Vader

Well-Known Member
Licensed User
Inline quotes are useful in long strings. For example if you copy some HTML string to your code it will be easier to convert the original string to a string with inline quotes then to change each quote into: " & QUOTE & ".

Possibly best if we agree to disagree ;)
 

Vader

Well-Known Member
Licensed User
I see it as confusing.
Consider this:
B4X:
Log("Hello, my name is "'Karl'")
Against this:
B4X:
Log("Hello, my name is ""Karl""")

Versus this:
B4X:
Log("Hello, my name is " & QUOTE & "Karl" & QUOTE)

[Note the colouring here is not truly representative of what the IDE will show, but what I am trying to show is that multiple quotes (that are sometime differing) can get lost easily]
As for the statement that it is easier to convert HTML with inline quotes, I usually perform an intermediate step of using Excel's columns to split my string up or build it as required. That way I get what I want to see, plus the ease of a tool (Excel) to do it for me.

I am of the opinion that readability of the final code is what is important, not the ease of writing it in the first place. Most people will read code many, many times more than the usual one go at writing it.

Anyway, I think at the end of the day it's horses for courses. ie whatever works for you :)

EDIT: At the end of the day inline quotes are a great feature because (some?) people use them and modern language compilers expect them.
 
Last edited:

kdgarris

Member
Licensed User
If nothing else, the ability to use inline quotes can greatly reduce line length vs using constants.
 
Top