Modify

Opened 15 years ago

Closed 11 years ago

#1649 closed Feature Request (Rejected)

Multiline strings without the "& _"

Reported by: JRowe Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: multiline strings Cc:

Description

This would be very useful to alleviate several cases where multi-line strings are useful, and the & _ syntax becomes clumsy or even difficult to work with.

It helps in both coding and making code readable.

I've been using multiline strings for string manipulation, in the building of MySQL queries, document parsing, in AuCGI, and various other areas.

$s_String = "This is a test." & _
"This is a continuation of the test." & _
"The ideal behavior for multi-line strings would be to emulate the appearance in the code file."
ConsoleWrite($s_String & @LF)
ConsoleWrite(@LF)
$s_String = "This is another test." & @LF & _
"This is a continuation of the other test." & @LF & _
"New lines should implicitly have @LF or @CR."
ConsoleWrite($s_String & @LF)

This is how I'd expect to write a multiline string - this would be very useful and save lots of time.

$s_String = "This is What I'd expect to write.
Another line.
The string would be an exact match to what's written here, with no awkward & _ syntax."

Attachments (0)

Change History (6)

comment:1 Changed 15 years ago by JRowe

I've been looking at other implementations, and one of the easiest to implement would seem to be using a unique token to indicate the beginning and end of a multi-line string.

Lua uses double brackets - the notation seems to be compatible with AutoIt, since we don't have anything similar.

I think the desired functionality would be to process the tokens, then concatenate each line with an appended LF character.

comment:2 Changed 15 years ago by Jpm

How can @CRLF be handled is the next line must be separated as windows text file.
Not sure the main Guru Dev will accept such request. the & _ concatenation seems to me a clean solution which allow the script designer to manage what he wants.

comment:3 follow-up: Changed 15 years ago by JRowe

The & _ concatenation is cumbersome and restrictive. The only viable alternative is to read external text files, which gets clunky.

A double bracket token could signify the beginning of a multi-line string. A single bracket could signify a temporary exit (for example, to insert a variable.) Here is my thought on the implementation of a raw multiline string:

If the preprocessor identifies and flags the double bracket token, then it should be simple to then parse each following line (CR, LF, or CRLF) and shape it into the current notation.

This:

$s_SomeVar = "Some Var"
$s_Multi = [["This is the beginning, the first line
And this is the second line
The third line has "] $s_SomeVar [" inserted
and the last line shows the closing token."]]

Would be transformed cleanly to this:

$s_SomeVar = "Some Var"
$s_Multi = "This is the beginning, the first line" & _
"And this is the second line" & _
"The third line has " & $s_SomeVar  & " inserted" & _
"and the last line shows the closing token."

This would be incredibly beneficial for interaction with SQL, dynamically generated code and text, ini manipulation, and more. I also think that it wouldn't represent a significant challenge as far as modifying the preprocessor goes, unless the structure behind "& _" has significantly changed since 2005. I'd be more than willing to do the legwork on the preprocessor if the publicly available code is still compatible with the current implementation (searching through it now.)

Is this idea worth bouncing around on the dev forum?

comment:4 Changed 15 years ago by Jpm

  • Owner set to Jon
  • Status changed from new to assigned

I leave to Jon the decision to close this ticket.
We discuss long time ago this splitting and " & _" was the decision at that time.

comment:5 in reply to: ↑ 3 Changed 15 years ago by mvg

Replying to JRowe:

Would be transformed cleanly to this:

$s_SomeVar = "Some Var"
$s_Multi = "This is the beginning, the first line" & _
"And this is the second line" & _
"The third line has " & $s_SomeVar  & " inserted" & _
"and the last line shows the closing token."
  • No linebreaks? (assuming they where forgotten...)
  • Which line-break code?. Forced CRLF, or current text-code based (which can change based on the path the text-code takes.)

comment:6 Changed 11 years ago by Jon

  • Resolution set to Rejected
  • Status changed from assigned to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.