Here document: Difference between revisions
Content deleted Content added
Langurmonkey (talk | contribs) |
added RPL |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 515:
=={{header|EasyLang}}==
<syntaxhighlight lang=text>
# The here-document is not here, but at the end of the program
repeat
Line 591:
A. Rimbaud "Voyelles"
</pre>
=={{header|ed}}==
<syntaxhighlight lang="sed">
# by Artyom Bologov
a
here
doc
.
,p
Q
</syntaxhighlight>
{{out}}
<pre>$ ed -s < heredoc.ed
here
doc</pre>
=={{header|Elixir}}==
Line 1,435 ⟶ 1,453:
print s
</pre>
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
begin
var s := '''
Multiline
string
with apostrophes ' and ''
''';
Write(s);
end.
</syntaxhighlight>
{{out}}
<pre>
Multiline
string
with apostrophes ' and ''
</pre>
Line 1,909 ⟶ 1,945:
good mem
to come to the aid of their country.
</pre>
=={{header|RPL}}==
« "Hi
there" → heredoc
« heredoc "!" +
» » '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
1: "Hi
there!"
</pre>
Line 2,461 ⟶ 2,508:
WshShell.Popup "created " & strFileNameOUT, 3, "Completed", 64
</syntaxhighlight>
=={{header|Vim Script}}==
Vim ''does'' have here documents (:h [https://vimhelp.org/eval.txt.html#%3Alet-heredoc :let-heredoc]). A heredoc sets an internal variable to a list containing the lines of text bounded by an end marker string, which must start with an uppercase letter. Therefore, to output the exact literal input, you need to join the list, either with builtin function [https://vimhelp.org/builtin.txt.html#join%28%29 join()], as in example 1, below, or use another function that joins inherently, as in example 2, below, which uses [https://vimhelp.org/builtin.txt.html#append%28%29 append()].
'''Example 1''' - simple, literal heredoc
<syntaxhighlight lang="vim">
let hw =<< END
Hello
World
END
echo join(hw, "\n")
</syntaxhighlight>
{{out}}
<pre>
Hello
World
</pre>
'''Example 2''' - evaluated heredoc
<syntaxhighlight lang="vim">
let d58 = "5 6 7 8"
let d =<< eval DOZEN
1 2 3 4 {d58}
9 10 11 12
DOZEN
call append(line('$'), d)
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8
9 10 11 12
</pre>
<small>NB: The output of example 2 is appended to the end of the current buffer if [https://vimhelp.org/repeat.txt.html#%3Asource-range '<,'>so] is executed on the visual selection from the lines starting "let d58" to "call append".</small>
=={{header|V (Vlang)}}==
|