Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language    [ Add a report in this area ]  
Report #:  2012   Status: Open
Compiler should accept multi-line strings without explicit string concatenation
Project:  Delphi Build #:  6.240
Version:    10.0 Submitted By:   FEDERICO BALBI
Report Type:  New Feature Request Date Reported:  8/5/2002 9:42:31 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   235232
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (42 Total Ratings)
3.71 out of 5
Total Votes: 301
Would be nice to have the compiler recognize a string constant that may take more than a line in the editor. This would simplify for example the SQL statements without having to concatenate multiple strings. It would make easier also copy and paste long SQL queries from/to .sql files.

Suggestions from comments:

Might I suggest a more C# style:

  SELECT DOB, gender, income
  FROM disney
  WHERE income > 1000000

Or even, dare I say it, use the other sort of quotation?

  SELECT DOB, gender, income
  FROM disney
  WHERE income > 1000000

Sysops Note: This would be a great thing for resourcestrings as well.
Steps to Reproduce:
right now:
line 1: s:='
line 2:       SELECT *
line 3:       FROM table1
line 4:       WHERE id=100
line5:      ';

will not compile b/c on 2 different lines. Would be nice to have a compiler directive to allow this.

henk holterman at 8/6/2002 2:46:09 PM -
Good idea, but might i suggest a more C/C++ like syntax:

const s = 'part 1'   ' part 2 '
  'part 3 '
'part 4 ';

yields   'part1 part 2 part 3 part 4 '

In other words, multiple string constants separated only by white space (space, tab, EOL) are merged by the compiler.  The drawback/benefit  is that you have to insert EOL explicitly.

FEDERICO BALBI at 8/6/2002 2:52:52 PM -
Thanks for your comment Henk.
Well, the C++ way still is not too handy because you still have to close each piece that makes the final string.
The way I proposed it would let you open the string, paste your big SQL statement and close it.
This will make long strings very easy to write and more readable.

henk holterman at 8/6/2002 3:04:26 PM -

Granted, but you are requesting a new language feature. That usually means it has to be very general an logical.  The C/C++ syntax allows precise control over the resulting string and will be usefull in more situations.

Your special case for SQL strings is very common, i've been there too. But it is probably better addressed by a special Paste command: 'Paste multiline string'. That could be realised  without a language change, maybe something for GExperts?


Alex Mackinnon at 8/7/2002 3:37:36 AM -
Maybe it could be done with a different opening and closing pair... such as /' and '/... if it is being done though it would be useful to add literal character translation either in the C form ("\r\n") or in the Pascal form (#37).

This would allow....

Caption.Text:=/'A nice long message -
possibly broken across multiple lines#13#10and including
any line breaks and stuff you want to add.#13#10'/

I think this approch would be a bit easier for the compiler to keep track of.

Peter Morris at 8/8/2002 3:18:40 AM -
I think it makes source look disgusting.

What is wrong with

MyString := 'Line 1' + #13#10 +
  'Line2 goes here' + #13#10 +
  'Line 3 goes here ' +
  'and more of line 3 here';

You must add deliberate line breaks, and it is 100% obvious where they are wouldn't you agree?

FEDERICO BALBI at 8/12/2002 12:04:06 PM -
Hey Peter,
  Actually the compiler should do the line breaks automatically... my suggestion is exactly to avoid your code.
I just want to be able to write a clean SQL statement on more lines without having to concatenate every line.
similar to the notepad-like memo that pops up when you modify a SQL property in a TQuery.
This way the code is much cleaner...

what is it more disgusting?

'SELECT DOB, gender, income' +
'FROM disney ' +
'WHERE income > 1000000';


  SELECT DOB, gender, income
  FROM disney
  WHERE income > 1000000

The second version IMHO is much cleaner during implementation.
Oracle for example let you do this. You can have a query on a text file of 100 lines and just copy and paste it between 2 hyphen instead of having to wrap every single line and add a "+".

Carl Kenner at 8/14/2002 7:22:45 AM -
Might I suggest a more C# style:

  SELECT DOB, gender, income
  FROM disney
  WHERE income > 1000000

Or even, dare I say it, use the other sort of quotation?

  SELECT DOB, gender, income
  FROM disney
  WHERE income > 1000000

Don Strenczewilk at 3/10/2005 4:20:11 AM -
Agreed. After using it in C#, I despise encoding and decoding multi-line strings in Delphi.

Radek Jedrasiak at 8/19/2002 6:19:06 AM -
Yes, that's one of those things Delphi should copy
from C# definitly. I like this idea.


Bojidar Alexandrov at 9/2/2002 2:48:39 AM -
If it will count for how many people requested this feature -  I support this too.

Wolfgang Junker at 9/4/2002 3:08:33 AM -
It doesn't count this way. If you _really_ request it, why does nobody vote for it?

FEDERICO BALBI at 9/4/2002 7:24:47 AM -
good point... let's vote!

Joe Bain at 3/9/2005 11:53:52 AM -
I would like this feature as well. I do not think any new syntax is needed like the @ or ".

FEDERICO BALBI at 8/16/2002 11:52:32 AM -
  your way is pretty good too!! Either mine or your would be great!!
I am tired concatenate all those chunks. It is very unreadable and hard to maintain.
Hope Borland will take alook at it.

gad lord at 1/6/2012 3:19:55 PM -
Maybe having the Dephi's special & symbol infornt of the string should make it multiline as the verbatim @ symbol in C#.

In this case you can have

sql =
&'select *
from Dual
where 1 = 1';

Just my 2c.

Russell Weetch at 9/14/2012 5:44:51 AM -
This would make my working day so much easier. I have been hankering after this since Delphi 1. This suggestion has been here since 2002. No response from Borland,Inprise,Embarcadero.... what's the problem? Just seems an excellent addition.

Bill Friedrich at 10/20/2012 5:14:15 AM -
The need to interface with other servers/devices using scripts continues to increase seemingly with exponential growth. (web languages, sql)  Working in a language like PHP makes me long for this feature in Delphi. (Although PHP's implementation is a little sloppy with white space.)

What about something as simple as this:

| procedure ExecuteQuery(CustomerTypeID:integer);
| begin
|   MyQuery.SQL.Text = '
|     select
|       FirstName,
|       LastName,
|       PhoneNumber
|     from
|       Customer
|     where
|       CustomerTypeID = ' + IntToStr(CustomerTypeID) + '
|     ';
|   MyQuery.Open;
| end;

Dealing with the white space removal is a little bit subtle, but it's worth it.
The exact SQL assigned to the Text property would be this:

| select<CR+LF>
|   FirstName,<CR+LF>
|   LastName,<CR+LF>
|   PhoneNumber<CR+LF>
| from<CR+LF>
|   Customer<CR+LF>
| where<CR+LF>
|   CustomerTypeID = 5<CR+LF>

The first cr/lf after the initial quote could be ignored (and a signal to the compiler that the next lines are in the multi-line format.)  The closing quote indicates the amount of whitespace to remove from each line.  A closing quote at the bottom and the format of the initial quote would be required.


Karol Bieniaszewski at 11/26/2012 11:44:46 PM -
This can couse many typing errors
I prefer double quote then single quote in this scenarion

Bill Friedrich at 11/29/2012 10:40:42 AM -
The reason I wouldn't want to change the quotes from single to anything else is because it would make moving snippets of code around Delphi programs a little tiresome.  Having to switch from one type of quote to another constantly would become a pain.  For example if you had:

FullName := LastName + ', ' + FirstName;

and you had to create a variable called FullAddress somewhere else in the code and you wanted to copy the  LastName + ', ' + FirstName  line, you would have to change the quotes after you pasted the snippet.

| FullAddress := "
| " + LastName + ", " + FirstName + "
| "  + Street + '
| " + City + ", " + State + " " + Zip + "
| ";


| FullAddress := '
|  ' + LastName + ', ' + FirstName + '
| '  + Street + '
| ' + City + ', ' + State + ' ' + Zip + '
| ';

Piotr Szychowski at 5/13/2013 4:46:37 AM -
Issue connected with report 114548

Server Response from: ETNACODE01