Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

Multiline string literals for B/S?

I find myself wanting that multiline string literals be supported in BrightScript - instead of manually assembling with `+ chr(10) +`. As simple as:
x = "Hello,
World!"

As somebody who's written interpreters i know it's not hard to implement. I imagine there might be concern of missing-quote error rolling down - but note above is now a supported syntax in VB, so such fear is greatly exagerrated https://github.com/dotnet/roslyn/wiki/N ... g-literals

I contemplated Python's:
x = """Hello,
World!"""
but alas that ship has sailed due to double-quote escape (i.e. tripple-quote """ is ambiguous if it's a literal with 1st char being a quote, or a multi-liner start). Tripling apostrophe may work but doesn't sound very BASIC (singular, it's used as REMark)

There is also Perl-style here-doc (PHP edition):

x = <<<END
Hello,
World!
END

There is attractiveness in "heredoc" in that there will be no need to escape quotes (") nor anything else if say including code - just select good marker and copy&paste between. Frankly this seems more and more desirable for my purposes.

Then there is the "cuckoo" operator (qq)... yeah, further alternatives head downhill in attractiveness.
0 Kudos
1 REPLY 1
Komag
Roku Guru

Re: Multiline string literals for B/S?

I type "naturally", making a new line whenever I want a new line, with each line being an entry of an array. Then a function takes the array and pulls out each line and adds the line break code to build a new array all properly coded. So my front end is almost what you want. Probably you already do something like that though 😉
0 Kudos