Hello world/Line printer: Difference between revisions

Content added Content deleted
(Added virtual printer support in EchoLisp)
No edit summary
Line 31:
end Print_Line;
</lang>
=={{header|ALGOL 68}}==
 
This task is VERY system and hardware dependent. The code below works
with Algol 68 Genie and a Linux system without /dev/lp0 but with a
remote printer interfaced via CUPS. Extending it to other
environments is left as an exercise for the reader.
<lang algol68>
BEGIN
STRING printer name = "/dev/lp0";
FILE line printer;
IF open (line printer, printer name, stand out channel) = 0
THEN
put (line printer, ("Hello world", newline));
close (line printer)
ELSE
put (stand error, ("Can't contact line printer on ", printer name, newline));
put (stand error, ("Trying to use lpr(1)", newline));
PIPE printer pipe = execve child pipe ("lpr", "", "");
IF pid OF printer pipe < 0 THEN
put (stand error, ("Oh dear, that didn't seem to work either. Giving up.", newline));
stop
FI;
put (write OF printer pipe, ("Hello world", newline));
close (read OF printer pipe);
close (write OF printer pipe)
FI
END
</lang> {{out}}
<pre>
Can't contact line printer on /dev/lp0
Trying to use lp(1)
</pre>
=={{header|Applesoft BASIC}}==