Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline string literal in Ada

How can I create a string in Ada containing newlines, whose definition also has those newlines?

I've tried with 0..2 backslashes at the end of the line, but none of that compiles:

   usage_info : String := "\
This should be the first line
and both the definition and the output
should contain newlines.";

In PHP this would be:

<<<BLOCK
1
2
3
BLOCK;

In C++ this would be:

const std::string s = "\
1
2
3";

In C#, it would be:

const string s =
@"1
2
3";
like image 859
TamaMcGlinn Avatar asked Dec 06 '25 14:12

TamaMcGlinn


1 Answers

From what I know, Ada , like Java, does not support multiline literal. The only thing I see is something like this:

usage_info : String := "This should be the first line" & CR & LF
                     & "and both the definition and the output" & CR & LF 
                     & "should contain newlines.";

Of course, you need to with and use Ada.Characters.Latin_1 to make these constants visible.

like image 138
Frédéric Praca Avatar answered Dec 09 '25 20:12

Frédéric Praca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!