Multiline Literal String

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Multiline Literal String

Post by eddy »

Is it possible to extend literal string syntax to support multiline text ?

It's more readable than a very long line with escape characters.
The text will be simplier to write and update without multiple constant insertions (#CRLF$ #LF$ or #LF$)
Of course, in this case the IDE should not break the literal string internal indentation.
Like common string, There's no comment inside multiline literal string.

Code: Select all

If myText$ = ""
        myText$ = ~"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ;end of literal string here ******
EndIf 
MessageRequester("Message", myText$)

Define hello.s= ~"\tHello\"Fred\", 
The semicolon [ ; ] has no special meaning inside this literal string or common string.
Regards\"John Doe\"" ;

MessageRequester("Message", hello)
Last edited by eddy on Sat Mar 05, 2016 3:34 pm, edited 3 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Julian
Enthusiast
Enthusiast
Posts: 276
Joined: Tue May 24, 2011 1:36 pm

Re: multiline literal string

Post by Julian »

eddy wrote:It's more readable than a very long line with escape characters.
Why would you need to read it in the editor?

Does it change often?

If so, put it into a text file and include it into the compilation. All your text is then in a separate file nicely formatted. You can then easily implement multi-language nice and easy too.

Huge strings in source code makes me :(

;)
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: multiline literal string

Post by eddy »

Julian wrote:
eddy wrote:It's more readable than a very long line with escape characters.
Why would you need to read it in the editor?
If so, put it into a text file and include it into the compilation. All your text is then in a separate file nicely formatted. You can then easily implement multi-language nice and easy too.

Huge strings in source code makes me :(

;)
Of course, you can't handle multi-language application string resources with some simple string variables.

I said this could be handy for day-to-day programming.
  • JSON
  • XML
  • XMLDialog
  • HTML
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply