Hello world/Line printer: Difference between revisions

m
(Adds slope example)
m (→‎{{header|Wren}}: Minor tidy)
 
(8 intermediate revisions by 8 users not shown)
Line 111:
PRINT "HELLO WORLD!"
</syntaxhighlight>
 
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">write "/dev/lp0" "Hello World\n"</syntaxhighlight>
 
=={{header|AutoHotkey}}==
Line 125 ⟶ 128:
 
=={{header|BASIC}}==
{{works with|GW-BASIC}}
{{works with|QBasic}}
{{works with|MSX BASIC}}
{{works with|ZX Spectrum Basic}}
{{works with|Liberty BASIC}}
Line 152 ⟶ 157:
PRINT #prn%, "Hello World!"
CLOSE #prn%</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|BASICA}}
{{works with|PC-BASIC}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">LPRINT "Hello World!"</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">LPRINT "Hello World!"</syntaxhighlight>
 
==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">LPRINT "Hello World!"</syntaxhighlight>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">OPEN #1: PRINTER !Open channel #1 for the printer
PRINT #1: "Hello World!"
END</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 422 ⟶ 441:
EZPF</syntaxhighlight>
 
==={{header| Alternative}} ===
As noted, null in the sense of zero cannot be used as a string terminator on EDSAC. However, it is possible to use the EDSAC null, whose 5-bit code is 10000. The subroutine below demonstrates this.
 
Line 553 ⟶ 572:
Print #1, "Hello World!"
Close #1</syntaxhighlight>
 
=={{header|FutureBasic}}==
The legacy lprint statemenet sends a line of text to the printer. The @(col,row) and %(h,v) options specify where on the page the line should be printed (see the print statement); if you don't specify one of these, the line is printed at the current pen position, usually just under the previously-printed line. lprint is inefficient if you are printing many lines to a page because it reroutes the output each time lprint is executed. In such cases, it's better to execute a sequence of print statements, with the entire sequence preceded by a single route _toPrinter statement and followed by a single route _toScreen statement. FB progammers today use much more sophisticated printer functions designed for complex pagination.
<syntaxhighlight lang="futurebasic">
// lprint [@(col,row)|%(h,v)] "Hello,World!"
lprint "Hello,World!"
route _toScreen
close lprint
</syntaxhighlight>
 
=={{header|Go}}==
Line 644 ⟶ 672:
print(); //Opens a dialog.
</syntaxhighlight>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">"/dev/lp" "w" fopen "Hello World!\n" fputchars fclose.</syntaxhighlight>
 
=={{header|Julia}}==
Line 749 ⟶ 780:
Assuming that the line printer is attached to /dev/lp0:
<syntaxhighlight lang="nim">var lp = open("/dev/lp0", fmWrite)
lp.writelnwriteLine "Hello World"
lp.close()</syntaxhighlight>
 
Line 949 ⟶ 980:
O 11 'Hello world'
</syntaxhighlight>
 
=={{header|RPL}}==
"Hello world!" PR1
 
=={{header|Ruby}}==
Line 1,039 ⟶ 1,073:
 
=={{header|Slope}}==
<syntaxhighlight>(file-append-to "/dev/lp0" "Hello world!")</syntaxhighlight>
 
=={{header|Smalltalk}}==
Line 1,130 ⟶ 1,164:
=={{header|Wren}}==
It is not currently possible to communicate with the printer using Wren-cli. So we need to write a minimal embedded program (no error checking) so the C host can do this for us.
<syntaxhighlight lang="ecmascriptwren">/* hello_world_line_printerHello_world_Line_printer.wren */
 
class C {
Line 1,139 ⟶ 1,173:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc hello_world_line_printerHello_world_Line_printer.c -o hello_world_line_printerHello_world_Line_printer -lwren -lm */
 
#include <stdio.h>
Line 1,194 ⟶ 1,228:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "hello_world_line_printerHello_world_Line_printer.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
9,482

edits