2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,4 +1,4 @@
|
|||
{{selection|Short Circuit|Console Program Basics}}
|
||||
{{selection|Short Circuit|Console Program Basics}}
|
||||
[[Category:Streams]]
|
||||
{{omit from|Applesoft BASIC}}
|
||||
{{omit from|bc|Always prints to standard output.}}
|
||||
|
|
@ -15,8 +15,12 @@ A common practice in computing is to send error messages
|
|||
to a different output stream than [[User Output - text|normal text console messages]].
|
||||
|
||||
The normal messages print to what is called "standard output" or "standard out".
|
||||
|
||||
The error messages print to "standard error".
|
||||
|
||||
This separation can be used to redirect error messages to a different place than normal messages.
|
||||
|
||||
Show how to print a message to standard error by printing "Goodbye, World!" on that stream.
|
||||
|
||||
;Task:
|
||||
Show how to print a message to standard error by printing '''Goodbye, World!''' on that stream.
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
10 PRINT #1;"Goodbye, World!"
|
||||
20 PAUSE 5: REM allow time for the user to see the error message
|
||||
20 PAUSE 50: REM allow time for the user to see the error message
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
say 'Goodbye, World!'
|
||||
call lineout 'STDERR', "Goodbye, World!"
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
call lineout 'STDERR', "Goodbye, World!"
|
||||
msgText = 'Goodbye, World!'
|
||||
call charout 'STDERR', msgText
|
||||
|
|
|
|||
|
|
@ -1,2 +1,14 @@
|
|||
msgText = 'Goodbye, World!'
|
||||
call charout 'STDERR', msgText
|
||||
/* REXX ---------------------------------------------------------------
|
||||
* 07.07.2014 Walter Pachl
|
||||
* enter the appropriate command shown in a command prompt.
|
||||
* "rexx serr.rex 2>err.txt"
|
||||
* or "regina serr.rex 2>err.txt"
|
||||
* 2>file will redirect the stderr stream to the specified file.
|
||||
* I don't know any other way to catch this stream
|
||||
*--------------------------------------------------------------------*/
|
||||
Parse Version v
|
||||
Say v
|
||||
Call lineout 'stderr','Good bye, world!'
|
||||
Call lineout ,'Hello, world!'
|
||||
Say 'and this is the error output:'
|
||||
'type err.txt'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
use std::io::{self,Write};
|
||||
|
||||
fn main() {
|
||||
writeln!(&mut io::stderr(), "Goodbye, world!").expect("Could not write to stderr");
|
||||
// writeln! supports formatted strings so the following works as well
|
||||
let goodbye = "Goodbye";
|
||||
let world = "world";
|
||||
writeln!(&mut io::stderr(), "{}, {}!", goodbye, world).expect("Could not write to stderr");
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use std::io::{self, Write};
|
||||
fn main() {
|
||||
io::stderr().write(b"Goodbye, world!").expect("Could not write to stderr");
|
||||
// With some finagling, you can do a formatted string here as well
|
||||
let goodbye = "Goodbye";
|
||||
let world = "world";
|
||||
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr");
|
||||
// Clearly, if you want formatted strings there's no reason not to just use writeln!
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
use std::io::{self,Write};
|
||||
|
||||
fn main() {
|
||||
let mut stderr = io::stderr();
|
||||
let bytes_read_or_error = stderr.write(b"Goodbye, World!\n");
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
() = fputs("Goodbye, World!\n", stderr);
|
||||
Loading…
Add table
Add a link
Reference in a new issue