This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,3 @@
{{selection|Short Circuit|Console Program Basics}}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.

View file

@ -0,0 +1,2 @@
---
note: Basic language learning

View file

@ -0,0 +1 @@
echoerr Goodbye, World!

View file

@ -0,0 +1,3 @@
main:(
put(stand error, ("Goodbye, World!", new line))
)

View file

@ -0,0 +1 @@
implement main () = fprint (stderr_ref, "Goodbye, World!\n")

View file

@ -0,0 +1,3 @@
BEGIN {
print "Goodbye, World!"| "cat 1>&2"
}

View file

@ -0,0 +1,3 @@
BEGIN {
print "Goodbye, World!" > "/dev/stderr"
}

View file

@ -0,0 +1,6 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Goodbye_World is
begin
Put_Line (Standard_Error, "Goodbye, World!");
end Goodbye_World;

View file

@ -0,0 +1,2 @@
use std
eprint "Goodbye, World!"

View file

@ -0,0 +1,2 @@
use std
eprintf "Goodbye, World!\n"

View file

@ -0,0 +1,2 @@
use std
fprintf stderr "Goodbye, World!\n"

View file

@ -0,0 +1,2 @@
; c:\> autohotkey.exe stderr.ahk 2> error.txt
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N

View file

@ -0,0 +1 @@
FileAppend, Goodbye`, World!, *

View file

@ -0,0 +1 @@
ConsoleWriteError("Goodbye, World!" & @CRLF)

View file

@ -0,0 +1,2 @@
10 PRINT #1;"Goodbye, World!"
20 PAUSE 5: REM allow time for the user to see the error message

View file

@ -0,0 +1,4 @@
STD_ERROR_HANDLE = -12
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1)
PRINT #13, "Goodbye, World!"
QUIT

View file

@ -0,0 +1 @@
1>&2 echo Goodbye, World!

View file

@ -0,0 +1,10 @@
#include <iostream>
using std::cerr;
using std::endl;
int main () {
cerr << "Goodbye, World!" << endl;
return cerr.bad();
}

View file

@ -0,0 +1,9 @@
#include <stdio.h>
int main()
{
fprintf(stderr, "Goodbye, ");
fputs("World!\n", stderr);
return 0;
}

View file

@ -0,0 +1 @@
message("Goodbye, World!")

View file

@ -0,0 +1,4 @@
program-id. ehello.
procedure division.
display "Goodbye, world!" upon syserr.
stop run.

View file

@ -0,0 +1,2 @@
(binding [*out* *err*]
(println "Goodbye, world!"))

View file

@ -0,0 +1 @@
console.warn "Goodbye, World!"

View file

@ -0,0 +1 @@
(format *error-output* "Goodbye, world!~%")

View file

@ -0,0 +1,5 @@
import std.stdio;
void main () {
stderr.writeln("Goodbye, World!");
}

View file

@ -0,0 +1,5 @@
import tango.io.Stdout;
void main () {
Stderr("Goodbye, World!").newline;
}

View file

@ -0,0 +1,7 @@
program Project1;
{$APPTYPE CONSOLE}
begin
WriteLn(ErrOutput, 'Goodbye, World!');
end.

View file

@ -0,0 +1 @@
Console::get_Error()::WriteLine("Goodbye World!")

View file

@ -0,0 +1,16 @@
//compile using the new dylan.NET v, 11.2.8.2 or later
//use mono to run the compiler
#refstdasm mscorlib.dll
import System
assembly stderrex exe
ver 1.1.0.0
class public auto ansi Module1
method public static void main()
Console::get_Error()::WriteLine("Goodbye World!")
end method
end class

View file

@ -0,0 +1 @@
stderr.println("Goodbye, World!")

View file

@ -0,0 +1 @@
io:put_chars(standard_error, "Goodbye, World!\n").

View file

@ -0,0 +1 @@
puts(2,"Goodbye, world!\n") -- 2 means output to 'standard error'

View file

@ -0,0 +1 @@
error-stream get [ "Goodbye, World! bbl, crashing" print flush ] with-output-stream*

View file

@ -0,0 +1,7 @@
class Main
{
public static Void main ()
{
Env.cur.err.printLine ("Goodbye, World!")
}
}

View file

@ -0,0 +1,4 @@
outfile-id
stderr to outfile-id
." Goodbye, World!" cr
to outfile-id

View file

@ -0,0 +1,9 @@
program StdErr
! Fortran 2003
use iso_fortran_env
! in case there's no module iso_fortran_env ...
!integer, parameter :: ERROR_UNIT = 0
write (ERROR_UNIT, *) "Goodbye, World!"
end program StdErr

View file

@ -0,0 +1,2 @@
package main
func main() { println("Goodbye, World!") }

View file

@ -0,0 +1,3 @@
package main
import ("fmt"; "os")
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }

View file

@ -0,0 +1 @@
System.err.println("Goodbye, World!")

View file

@ -0,0 +1,2 @@
import System.IO
main = hPutStrLn stderr "Goodbye, World!"

View file

@ -0,0 +1,3 @@
procedure main()
write(&errout, "Goodbye World" )
end

View file

@ -0,0 +1,2 @@
stderr =: 1!:2&4
stderr 'Goodbye, World!'

View file

@ -0,0 +1,5 @@
public class Err{
public static void main(String[] args){
System.err.println("Goodbye, World!");
}
}

View file

@ -0,0 +1 @@
WScript.StdErr.WriteLine("Goodbye, World!");

View file

@ -0,0 +1 @@
console.warn("Goodbye, World!")

View file

@ -0,0 +1 @@
io.stderr:write("Goodbye, World!\n")

View file

@ -0,0 +1 @@
error 'Goodbye, World!'

View file

@ -0,0 +1,2 @@
MCSET S4=1
MCNOTE Goodbye, World!

View file

@ -0,0 +1 @@
Write[Streams["stderr"], "Goodbye, World!"]

View file

@ -0,0 +1,11 @@
:- module hello_error.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
io.stderr_stream(Stderr, !IO),
io.write_string(Stderr, "Goodbye, World!\n", !IO).

View file

@ -0,0 +1,3 @@
errmessage "Error";
message "...going on..."; % if the user decides to go on and not to stop
% the program because of the error.

View file

@ -0,0 +1,7 @@
MODULE HelloErr;
IMPORT StdError;
BEGIN
StdError.WriteString('Goodbye, World!');
StdError.WriteLn
END HelloErr.

View file

@ -0,0 +1,7 @@
MODULE Stderr EXPORTS Main;
IMPORT Wr, Stdio;
BEGIN
Wr.PutText(Stdio.stderr, "Goodbye, World!\n");
END Stderr.

View file

@ -0,0 +1 @@
fprintf(STDERR, "Goodbye, World!\n");

View file

@ -0,0 +1 @@
file_put_contents("php://stderr","Hello World!\n");

View file

@ -0,0 +1 @@
warn "Goodbye, World!\n";

View file

@ -0,0 +1 @@
print STDERR "Goodbye, World!\n";

View file

@ -0,0 +1 @@
(out 2 (prinl "Goodbye, World!"))

View file

@ -0,0 +1,3 @@
import sys
print >> sys.stderr, "Goodbye, World!"

View file

@ -0,0 +1,3 @@
import sys
print("Goodbye, World!", file=sys.stderr)

View file

@ -0,0 +1,3 @@
import sys
sys.stderr.write("Goodbye, World!\n")

View file

@ -0,0 +1 @@
cat("Goodbye, World!", file=stderr())

View file

@ -0,0 +1 @@
say 'Goodbye, World!'

View file

@ -0,0 +1 @@
say "Goodbye, World!"

View file

@ -0,0 +1 @@
call lineout ,"Goodbye, World!"

View file

@ -0,0 +1 @@
call charout ,"Goodbye, World!"

View file

@ -0,0 +1 @@
(eprintf "Goodbye, World!\n")

View file

@ -0,0 +1 @@
$stderr.puts "Goodbye, World!"

View file

@ -0,0 +1 @@
warn "Goodbye, World!"

View file

@ -0,0 +1,5 @@
class MAIN is
main is
#ERR + "Hello World!\n";
end;
end;

View file

@ -0,0 +1 @@
System.err.println("Goodbye, World!")

View file

@ -0,0 +1 @@
Console.err.println("Goodbye, World!")

View file

@ -0,0 +1 @@
(error "Goodbye, World!")

View file

@ -0,0 +1 @@
puts stderr "Goodbye, World!"