Copy stdin to stdout: Difference between revisions
Content added Content deleted
(Applesoft BASIC) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 5: | Line 5: | ||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |
||
< |
<syntaxhighlight lang="asm">READ: equ 3Fh ; MS-DOS syscalls |
||
WRITE: equ 40h |
WRITE: equ 40h |
||
BUFSZ: equ 4000h ; Buffer size |
BUFSZ: equ 4000h ; Buffer size |
||
Line 26: | Line 26: | ||
done: ret |
done: ret |
||
section .bss |
section .bss |
||
buffer: resb BUFSZ</ |
buffer: resb BUFSZ</syntaxhighlight> |
||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
< |
<syntaxhighlight lang="action!">PROC Main() |
||
CHAR c |
CHAR c |
||
Line 37: | Line 37: | ||
UNTIL c=27 ;repeat until Esc key is pressed |
UNTIL c=27 ;repeat until Esc key is pressed |
||
OD |
OD |
||
RETURN</ |
RETURN</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Copy_stdin_to_stdout.png Screenshot from Atari 8-bit computer] |
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Copy_stdin_to_stdout.png Screenshot from Atari 8-bit computer] |
||
Line 46: | Line 46: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">with Ada.Text_IO; |
||
procedure Copy_Stdin_To_Stdout is |
procedure Copy_Stdin_To_Stdout is |
||
Line 56: | Line 56: | ||
Put (C); |
Put (C); |
||
end loop; |
end loop; |
||
end Copy_Stdin_To_Stdout;</ |
end Copy_Stdin_To_Stdout;</syntaxhighlight> |
||
=={{header|Aime}}== |
=={{header|Aime}}== |
||
< |
<syntaxhighlight lang="aime">file f; |
||
data b; |
data b; |
||
f.stdin; |
f.stdin; |
||
while (f.b_line(b) ^ -1) { |
while (f.b_line(b) ^ -1) { |
||
o_(b, "\n"); |
o_(b, "\n"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}} |
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}} |
||
< |
<syntaxhighlight lang="algol68">BEGIN |
||
BOOL at eof := FALSE; |
BOOL at eof := FALSE; |
||
# set the EOF handler for stand in to a procedure that sets "at eof" to true # |
# set the EOF handler for stand in to a procedure that sets "at eof" to true # |
||
Line 75: | Line 75: | ||
# copy stand in to stand out # |
# copy stand in to stand out # |
||
WHILE STRING line; read( ( line, newline ) ); NOT at eof DO write( ( line, newline ) ) OD |
WHILE STRING line; read( ( line, newline ) ); NOT at eof DO write( ( line, newline ) ) OD |
||
END</ |
END</syntaxhighlight> |
||
=={{header|Applesoft BASIC}}== |
=={{header|Applesoft BASIC}}== |
||
< |
<syntaxhighlight lang="gwbasic">0 GET C$ : PRINT C$; : GOTO</syntaxhighlight> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
Using the awk interpreter, the following command uses the pattern // (which matches anything) with the default action (which is to print the current line) and so copy lines from stdin to stdut. |
Using the awk interpreter, the following command uses the pattern // (which matches anything) with the default action (which is to print the current line) and so copy lines from stdin to stdut. |
||
< |
<syntaxhighlight lang="awk">awk "//"</syntaxhighlight> |
||
=={{header|BCPL}}== |
=={{header|BCPL}}== |
||
< |
<syntaxhighlight lang="bcpl">get "libhdr" |
||
let start() be |
let start() be |
||
Line 90: | Line 90: | ||
if c = endstreamch then finish |
if c = endstreamch then finish |
||
wrch(c) |
wrch(c) |
||
$) repeat</ |
$) repeat</syntaxhighlight> |
||
=={{header|Brainf***}}== |
=={{header|Brainf***}}== |
||
<lang |
<syntaxhighlight lang="brainf***">,[.,]</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
<syntaxhighlight lang="c"> |
|||
<lang C> |
|||
#include <stdio.h> |
#include <stdio.h> |
||
Line 106: | Line 106: | ||
return 0; |
return 0; |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
{{works with|.NET Framework|4.0 or later}} |
{{works with|.NET Framework|4.0 or later}} |
||
< |
<syntaxhighlight lang="csharp"> |
||
using System; |
using System; |
||
Line 120: | Line 120: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
< |
<syntaxhighlight lang="cpp">#include <iostream> |
||
#include <iterator> |
#include <iterator> |
||
Line 135: | Line 135: | ||
); |
); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
Shorter and quicker alternative: |
Shorter and quicker alternative: |
||
< |
<syntaxhighlight lang="cpp">#include <iostream> |
||
int main() { |
int main() { |
||
std::cout << std::cin.rdbuf(); |
std::cout << std::cin.rdbuf(); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|CLU}}== |
=={{header|CLU}}== |
||
< |
<syntaxhighlight lang="clu">start_up = proc () |
||
pi: stream := stream$primary_input() |
pi: stream := stream$primary_input() |
||
po: stream := stream$primary_output() |
po: stream := stream$primary_output() |
||
Line 154: | Line 154: | ||
return |
return |
||
end |
end |
||
end start_up</ |
end start_up</syntaxhighlight> |
||
=={{header|Commodore BASIC}}== |
=={{header|Commodore BASIC}}== |
||
Line 193: | Line 193: | ||
The following program opens channels to devices chosen by the user, then uses the GET# and PRINT# I/O statements instead of the standard GET and PRINT (for typical keyboard/screen interaction.) When keyboard and/or screen are chosen, BASIC ignores the extra filename and file type parameters normally used for other devices. Peripheral devices (tape, disk drive) use STATUS register to flag end of file, however the keyboard does not. When using the keyboard, the program terminates on a CTRL-Z. |
The following program opens channels to devices chosen by the user, then uses the GET# and PRINT# I/O statements instead of the standard GET and PRINT (for typical keyboard/screen interaction.) When keyboard and/or screen are chosen, BASIC ignores the extra filename and file type parameters normally used for other devices. Peripheral devices (tape, disk drive) use STATUS register to flag end of file, however the keyboard does not. When using the keyboard, the program terminates on a CTRL-Z. |
||
< |
<syntaxhighlight lang="gwbasic">10 print chr$(147);chr$(14); |
||
11 print "0:Keyboard 1:Tape 2:RS-232 3:Screen" |
11 print "0:Keyboard 1:Tape 2:RS-232 3:Screen" |
||
12 print "4-7:printers/plotters" |
12 print "4-7:printers/plotters" |
||
Line 207: | Line 207: | ||
50 if (d1=0 and a$=chr$(26)) or (d1>0 and st>0) then close 5:close 2:end |
50 if (d1=0 and a$=chr$(26)) or (d1>0 and st>0) then close 5:close 2:end |
||
60 print#2,a$; |
60 print#2,a$; |
||
70 goto 40</ |
70 goto 40</syntaxhighlight> |
||
{{output}} |
{{output}} |
||
Line 264: | Line 264: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">#|Loops while reading and collecting characters from STDIN until EOF (C-Z or C-D) |
||
Then concatenates the characters into a string|# |
Then concatenates the characters into a string|# |
||
(format t |
(format t |
||
(concatenate 'string |
(concatenate 'string |
||
(loop for x = (read-char *query-io*) until (or (char= x #\Sub) (char= x #\Eot)) collecting x))) |
(loop for x = (read-char *query-io*) until (or (char= x #\Sub) (char= x #\Eot)) collecting x))) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Crystal}}== |
=={{header|Crystal}}== |
||
< |
<syntaxhighlight lang="ruby">STDIN.each_line do |line| |
||
puts line |
puts line |
||
end</ |
end</syntaxhighlight> |
||
=={{header|D}}== |
=={{header|D}}== |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
Line 283: | Line 283: | ||
writeln(line); |
writeln(line); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Dart}}== |
=={{header|Dart}}== |
||
< |
<syntaxhighlight lang="dart">import 'dart:io'; |
||
void main() { |
void main() { |
||
var line = stdin.readLineSync(); |
var line = stdin.readLineSync(); |
||
stdout.write(line); |
stdout.write(line); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 297: | Line 297: | ||
=={{header|Draco}}== |
=={{header|Draco}}== |
||
< |
<syntaxhighlight lang="draco">\util.g |
||
proc nonrec main() void: |
proc nonrec main() void: |
||
Line 318: | Line 318: | ||
esac |
esac |
||
do od |
do od |
||
corp</ |
corp</syntaxhighlight> |
||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
< |
<syntaxhighlight lang="fsharp"> |
||
let copy()=let n,g=stdin,stdout |
let copy()=let n,g=stdin,stdout |
||
let rec fN()=match n.ReadLine() with "EOF"->g.Write "" |i->g.WriteLine i; fN() |
let rec fN()=match n.ReadLine() with "EOF"->g.Write "" |i->g.WriteLine i; fN() |
||
fN() |
fN() |
||
copy() |
copy() |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
< |
<syntaxhighlight lang="factor">USING: io kernel ; |
||
[ read1 dup ] [ write1 ] while drop</ |
[ read1 dup ] [ write1 ] while drop</syntaxhighlight> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
{{works with|gforth|0.7.3}} |
{{works with|gforth|0.7.3}} |
||
<lang |
<syntaxhighlight lang="forth">stdin slurp-fid type bye</syntaxhighlight> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">#define FIN 255 'eof is already a reserved word |
||
#include "crt/stdio.bi" 'provides the C functions getchar and putchar |
#include "crt/stdio.bi" 'provides the C functions getchar and putchar |
||
dim as ubyte char |
dim as ubyte char |
||
Line 344: | Line 344: | ||
char = getchar() |
char = getchar() |
||
if char = FIN then exit do else putchar(char) |
if char = FIN then exit do else putchar(char) |
||
loop</ |
loop</syntaxhighlight> |
||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
The special string "-" indicates reading from stdin. |
The special string "-" indicates reading from stdin. |
||
< |
<syntaxhighlight lang="frink">print[read["-"]]</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 370: | Line 370: | ||
w.Flush() |
w.Flush() |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">class StdInToStdOut { |
||
static void main(args) { |
static void main(args) { |
||
try (def reader = System.in.newReader()) { |
try (def reader = System.in.newReader()) { |
||
Line 382: | Line 382: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">main = interact id </syntaxhighlight> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
Copies until no more input. |
Copies until no more input. |
||
< |
<syntaxhighlight lang="java"> |
||
import java.util.Scanner; |
import java.util.Scanner; |
||
Line 404: | Line 404: | ||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Output interleaved. Stdin and Stdout are same window. |
Output interleaved. Stdin and Stdout are same window. |
||
Line 417: | Line 417: | ||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
JavaScript in the browser does not have a stdin or stdout, but using Node.js we have: |
JavaScript in the browser does not have a stdin or stdout, but using Node.js we have: |
||
< |
<syntaxhighlight lang="javascript">process.stdin.resume(); |
||
process.stdin.pipe(process.stdout);</ |
process.stdin.pipe(process.stdout);</syntaxhighlight> |
||
< |
<syntaxhighlight lang="bash">node index.js < index.js</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 428: | Line 428: | ||
=={{header|jq}}== |
=={{header|jq}}== |
||
<lang |
<syntaxhighlight lang="jq">jq -Rr .</syntaxhighlight> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia">while !eof(stdin) |
||
write(stdout, read(stdin, UInt8)) |
write(stdout, read(stdin, UInt8)) |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<syntaxhighlight lang="scala">fun main() { |
||
var c: Int |
var c: Int |
||
do { |
do { |
||
Line 442: | Line 442: | ||
System.out.write(c) |
System.out.write(c) |
||
} while (c >= 0) |
} while (c >= 0) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Latitude}}== |
=={{header|Latitude}}== |
||
< |
<syntaxhighlight lang="latitude">while { $stdin eof? not. } do { |
||
$stdout putln: $stdin readln. |
$stdout putln: $stdin readln. |
||
}.</ |
}.</syntaxhighlight> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
Line 453: | Line 453: | ||
=={{header|Mercury}}== |
=={{header|Mercury}}== |
||
<syntaxhighlight lang="mercury"> |
|||
<lang Mercury> |
|||
:- module stdin_to_stdout. |
:- module stdin_to_stdout. |
||
Line 496: | Line 496: | ||
%-----------------------------------------------------------------------------% |
%-----------------------------------------------------------------------------% |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
<lang |
<syntaxhighlight lang="nim">stdout.write readAll(stdin)</syntaxhighlight> |
||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">try |
||
while true do |
while true do |
||
output_char stdout (input_char stdin) |
output_char stdout (input_char stdin) |
||
done |
done |
||
with End_of_file -> ()</ |
with End_of_file -> ()</syntaxhighlight> |
||
=={{header|Ol}}== |
=={{header|Ol}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
(bytestream->port (port->bytestream stdin) stdout) |
(bytestream->port (port->bytestream stdin) stdout) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
< |
<syntaxhighlight lang="pascal">program writeInput(input, output); |
||
var |
var |
||
buffer: char; |
buffer: char; |
||
Line 525: | Line 525: | ||
write(buffer); // shorthand for write(output, buffer) |
write(buffer); // shorthand for write(output, buffer) |
||
end; |
end; |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl"> |
||
perl -pe '' |
perl -pe '' |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang="phix">(notonline)--> |
||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> |
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> |
||
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span> |
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span> |
||
Line 540: | Line 540: | ||
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">)</span> |
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
<lang |
<syntaxhighlight lang="picolisp">(in NIL (echo))</syntaxhighlight> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
<syntaxhighlight lang="prolog"> |
|||
<lang Prolog> |
|||
%File: stdin_to_stdout.pl |
%File: stdin_to_stdout.pl |
||
:- initialization(main). |
:- initialization(main). |
||
Line 555: | Line 555: | ||
X == end_of_file, |
X == end_of_file, |
||
fail. |
fail. |
||
</syntaxhighlight> |
|||
</lang> |
|||
Invocation at the command line (with Swi-prolog): |
Invocation at the command line (with Swi-prolog): |
||
<syntaxhighlight lang="sh"> |
|||
<lang sh> |
|||
swipl stdin_to_stdout.pl |
swipl stdin_to_stdout.pl |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Python}}== |
=={{header|Python}}== |
||
Line 569: | Line 569: | ||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(let loop () |
(let loop () |
||
Line 575: | Line 575: | ||
[(? eof-object?) (void)] |
[(? eof-object?) (void)] |
||
[c (display c) |
[c (display c) |
||
(loop)]))</ |
(loop)]))</syntaxhighlight> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 581: | Line 581: | ||
When invoked at a command line: Slightly less magical than Perl / sed. The p flag means automatically print each line of output to STDOUT. The e flag means execute what follows inside quotes. ".lines" reads lines from the assigned pipe (file handle), STDIN by default. |
When invoked at a command line: Slightly less magical than Perl / sed. The p flag means automatically print each line of output to STDOUT. The e flag means execute what follows inside quotes. ".lines" reads lines from the assigned pipe (file handle), STDIN by default. |
||
<lang |
<syntaxhighlight lang="raku" line>raku -pe'.lines'</syntaxhighlight> |
||
When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print) |
When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print) |
||
<lang |
<syntaxhighlight lang="raku" line>.say for lines</syntaxhighlight> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 592: | Line 592: | ||
normally the console. So for REXX, this task equates to copying data |
normally the console. So for REXX, this task equates to copying data |
||
from the console to itself. |
from the console to itself. |
||
< |
<syntaxhighlight lang="rexx">/*REXX pgm copies data from STDIN──►STDOUT (default input stream──►default output stream*/ |
||
do while chars()\==0 /*repeat loop until no more characters.*/ |
do while chars()\==0 /*repeat loop until no more characters.*/ |
||
call charin , x /*read a char from the input stream. */ |
call charin , x /*read a char from the input stream. */ |
||
call charout , x /*write " " " " output " */ |
call charout , x /*write " " " " output " */ |
||
end /*while*/ /*stick a fork in it, we're all done. */</ |
end /*while*/ /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
? "give input: " give str |
? "give input: " give str |
||
? "output: " + str |
? "output: " + str |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 612: | Line 612: | ||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
< |
<syntaxhighlight lang="rust">use std::io; |
||
fn main() { |
fn main() { |
||
io::copy(&mut io::stdin().lock(), &mut io::stdout().lock()); |
io::copy(&mut io::stdin().lock(), &mut io::stdout().lock()); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
Line 622: | Line 622: | ||
For Scala 2's compiler <code>scalac</code>, a containing object is required: |
For Scala 2's compiler <code>scalac</code>, a containing object is required: |
||
< |
<syntaxhighlight lang="scala">object CopyStdinToStdout extends App { |
||
io.Source.fromInputStream(System.in).getLines().foreach(println) |
io.Source.fromInputStream(System.in).getLines().foreach(println) |
||
}</ |
}</syntaxhighlight> |
||
If it's being run directly by <code>scala</code>, it can be shortened to one line, and run directly in the shell: |
If it's being run directly by <code>scala</code>, it can be shortened to one line, and run directly in the shell: |
||
< |
<syntaxhighlight lang="bash">scala -e "io.Source.fromInputStream(System.in).getLines().foreach(println)"</syntaxhighlight> |
||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
(do ((c (read-char) (read-char))) |
(do ((c (read-char) (read-char))) |
||
((eof-object? c) 'done) |
((eof-object? c) 'done) |
||
(display c)) |
(display c)) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|sed}}== |
=={{header|sed}}== |
||
<syntaxhighlight lang="sh"> |
|||
<lang sh> |
|||
sed -e '' |
sed -e '' |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
include "fileutil.s7i"; |
include "fileutil.s7i"; |
||
Line 652: | Line 652: | ||
begin |
begin |
||
copyFile(IN, OUT); |
copyFile(IN, OUT); |
||
end func;</ |
end func;</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
{{Works with|Smalltalk/X}} |
{{Works with|Smalltalk/X}} |
||
< |
<syntaxhighlight lang="smalltalk">"using Stream class's bulk copy method:" |
||
Stdin copyToEndInto:Stdout. |
Stdin copyToEndInto:Stdout. |
||
Line 668: | Line 668: | ||
[ |
[ |
||
[ Stdout nextPut:(Stdin next) ] loop. |
[ Stdout nextPut:(Stdin next) ] loop. |
||
] on: StreamError do:[]</ |
] on: StreamError do:[]</syntaxhighlight> |
||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
< |
<syntaxhighlight lang="sml">fun copyLoop () = |
||
case TextIO.input TextIO.stdIn of |
case TextIO.input TextIO.stdIn of |
||
"" => () |
"" => () |
||
| tx => copyLoop (TextIO.output (TextIO.stdOut, tx)) |
| tx => copyLoop (TextIO.output (TextIO.stdOut, tx)) |
||
val () = copyLoop ()</ |
val () = copyLoop ()</syntaxhighlight> |
||
=={{header|Symsyn}}== |
=={{header|Symsyn}}== |
||
<syntaxhighlight lang="symsyn"> |
|||
<lang Symsyn> |
|||
Loop [] [] |
Loop [] [] |
||
go Loop |
go Loop |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
< |
<syntaxhighlight lang="tcl">package require Tcl 8.5 |
||
chan copy stdin stdout |
chan copy stdin stdout |
||
# fcopy stdin stdout for older versions</ |
# fcopy stdin stdout for older versions</syntaxhighlight> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
VBScript can't get single chars from stdin, so we have to implement it line to line. Ctrl-Z+Enter stops. |
VBScript can't get single chars from stdin, so we have to implement it line to line. Ctrl-Z+Enter stops. |
||
<syntaxhighlight lang="vb"> |
|||
<lang vb> |
|||
do |
do |
||
s=wscript.stdin.readline |
s=wscript.stdin.readline |
||
wscript.stdout.writeline s |
wscript.stdout.writeline s |
||
loop until asc(left(s,1))=26 |
loop until asc(left(s,1))=26 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
Line 703: | Line 703: | ||
Bytes are read from stdin and written to stdout until the return key is pressed. |
Bytes are read from stdin and written to stdout until the return key is pressed. |
||
< |
<syntaxhighlight lang="ecmascript">import "io" for Stdin, Stdout |
||
Stdin.isRaw = true // prevents echoing to the terminal |
Stdin.isRaw = true // prevents echoing to the terminal |
||
Line 713: | Line 713: | ||
} |
} |
||
System.print() |
System.print() |
||
Stdin.isRaw = false</ |
Stdin.isRaw = false</syntaxhighlight> |
||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
Line 719: | Line 719: | ||
stdout, which displays the character on the monitor. This program can |
stdout, which displays the character on the monitor. This program can |
||
list a file to the screen like this: stdio <file.txt |
list a file to the screen like this: stdio <file.txt |
||
< |
<syntaxhighlight lang="xpl0">int C; |
||
loop [C:= ChIn(1); |
loop [C:= ChIn(1); |
||
if C = $1A \EOF\ then quit; |
if C = $1A \EOF\ then quit; |
||
ChOut(0, C); |
ChOut(0, C); |
||
]</ |
]</syntaxhighlight> |
||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
< |
<syntaxhighlight lang="zkl">zkl --eval "File.stdout.write(File.stdin.read())"</syntaxhighlight> |