Hello world/Standard error: Difference between revisions

(Adds slope example)
 
(18 intermediate revisions by 14 users not shown)
Line 6:
{{omit from|Brainf***}}
{{omit from|dc|Always prints to standard output.}}
{{omit from|EasyLang|EasyLang has an error variable, but it cannot be set manually. And it always prints to standard output.}}
{{omit from|GUISS|Cannot customize error messages}}
{{omit from|Integer BASIC}}
Line 178 ⟶ 179:
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
{{works with|QBasic}}
<syntaxhighlight lang="basic">REM FILE-BASED OUTPUT REDIRECTION
0 D$ = CHR$ (4):F$ = "DEV/STDERR": PRINT D$"OPEN"F$: PRINT D$"CLOSE"F$: PRINT D$"APPEND"F$: PRINT D$"WRITE"F$
ON ERROR GOTO ManejoErrores
1 PRINT "GOODBYE, WORLD!"
ERROR 99
2 PRINT D$"CLOSE"F$</syntaxhighlight><syntaxhighlight lang="basic">REM OUTPUT ROUTINE REDIRECTION
END
3 FOR I = 768 TO 802: READ B: POKE I,B: NEXT : POKE 54,0: POKE 55,3: CALL 1002: DATA 72,173,34,3,208,8,169,191,141,34,3,32,240,253,104,201,141,208,12,169,0,141,34,3,169,135,32,240,253,169,141,76,240,253,0
 
4 O$ = CHR$ (111):D$ = CHR$ (100): PRINT "G" + O$ + O$ + D$ + CHR$ (98) + CHR$ (121) + CHR$ (101) + ", W" + O$ + CHR$ (114) + CHR$ (108) + D$ + "!"
 
5 POKE 54,240: POKE 55,253: CALL 1002</syntaxhighlight>
ManejoErrores:
PRINT "Googbye World!"
RESUME
</syntaxhighlight>
 
==={{header|BaCon}}===
<syntaxhighlight lang="freebasic">EPRINT "Goodbye, World!"</syntaxhighlight>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">onerror errortrap
onerror errortrap
throwerror 99
end
 
 
errortrap:
print "Goodbye World!"
return</syntaxhighlight>
 
</syntaxhighlight>
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">10 cls
20 on error goto 50
30 error 99 : we force an error
40 end
50 rem ManejoErrores
60 print "Goodbye World!"
70 cont</syntaxhighlight>
 
==={{header|QBasic}}===
<syntaxhighlight lang="basic">ON ERROR GOTO ManejoErrores
ERROR 99
END
 
ManejoErrores:
PRINT "Googbye World!"
RESUME</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
 
On the ZX Spectrum, standard error is on stream 1:
 
<syntaxhighlight lang="zxbasic">10 PRINT #1;"Goodbye, World!"
20 PAUSE 50: REM allow time for the user to see the error message</syntaxhighlight>
10 PRINT #1;"Goodbye, World!"
20 PAUSE 50: REM allow time for the user to see the error message
</syntaxhighlight>
 
=={{header|Batch File}}==
Line 322 ⟶ 332:
WriteLn(ErrOutput, 'Goodbye, World!');
end.</syntaxhighlight>
 
=={{header|dt}}==
<syntaxhighlight lang="dt">"Goodbye, World!" epl</syntaxhighlight>
 
=={{header|Dylan.NET}}==
Line 372 ⟶ 385:
 
<syntaxhighlight lang="lisp">(princ "Goodbye, World!\n" 'external-debugging-output)</syntaxhighlight>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">logLine("Goodbye, World!")</syntaxhighlight>
<syntaxhighlight lang="emal">log("Goodbye, World!")</syntaxhighlight>
 
=={{header|Erlang}}==
Line 486 ⟶ 503:
 
=={{header|J}}==
<syntaxhighlight lang="j">stderr =: 1!:2&4 stderr
1!:2&5
stderr 'Goodbye, World!'</syntaxhighlight>
 
0 0 $ stderr 'Goodbye, World!'</syntaxhighlight>
 
=={{header|Java}}==
Line 507 ⟶ 526:
OR
<syntaxhighlight lang="javascript">throw new Error("Goodbye, World!")//Should work in any browser</syntaxhighlight>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">stderr "Goodbye, World!\n" fputchars pop.</syntaxhighlight>
 
=={{header|jq}}==
 
<syntaxhighlight lang="jq">jq -n —-arg s 'Goodbye, World!' '$s | stderr | empty'</syntaxhighlight>
 
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above.
 
=={{header|Julia}}==
 
Julia 0.7 or newer:
 
<syntaxhighlight lang="julia">println(stderr, "Goodbye, World!")</syntaxhighlight>
 
In versions prior to Julia 0.7, the standard I/O streams were capitalized:
 
<syntaxhighlight lang="julia">println(STDERR, "Goodbye, World!")</syntaxhighlight>
 
Line 521 ⟶ 548:
System.err.println("Goodbye, World!")
}</syntaxhighlight>
 
=={{header|Lang}}==
<syntaxhighlight lang="lang">fn.errorln(Goodbye, World!)</syntaxhighlight>
 
=={{header|langur}}==
<syntaxhighlight lang="langur">writelnErr "goodbyeGoodbye, peopleworld."</syntaxhighlight>
 
=={{header|Lasso}}==
Line 551 ⟶ 581:
sx.shell_cmd("logger Goodbye, World!")</syntaxhighlight>
 
=={{header|Lean}}==
In lean4
<syntaxhighlight lang="lean4">
def main : IO Unit := do
let stderr ← IO.getStderr
stderr.putStrLn s!"Goodbye, World!"
</syntaxhighlight>
=={{header|LLVM}}==
<syntaxhighlight lang="llvm">; This is not strictly LLVM, as it uses the C library function "printf".
Line 637 ⟶ 674:
message "...going on..."; % if the user decides to go on and not to stop
% the program because of the error.</syntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.37.0}}
Currently, ''min'' has three possibilities for outputting to stderr:
<syntaxhighlight lang="min">"Goodbye, World!" warn!
"Goodbye, World!" error!
"Goodbye, World!" fatal!</syntaxhighlight>
The first two depend on the current log level (and are enabled by default). The last one additionally terminates the program.
 
=={{header|ML/I}}==
<syntaxhighlight lang="ml/i">MCSET S4=1
MCNOTE Goodbye, World!</syntaxhighlight>
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stderr "Hello, world!\n"]</syntaxhighlight>
 
=={{header|Modula-2}}==
Line 703 ⟶ 752:
 
=={{header|Nim}}==
<syntaxhighlight lang="nim">stderr.writelnwriteLine "Hello World"</syntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
print -e "Goodbye, World!"
</syntaxhighlight>
 
=={{header|Oberon-2}}==
Line 941 ⟶ 995:
=={{header|Ring}}==
<syntaxhighlight lang="ring">fputs(stderr,"Goodbye, World!")</syntaxhighlight>
 
=={{header|RPL}}==
There is no error console in RPL but all error messages are displayed at the top two lines of the display, which freezes until a key is pressed.
This can be mimicked with the <code>DISP</code> instruction:
≪ "Hello world!" 1 DISP ≫
 
=={{header|Ruby}}==
Line 1,188 ⟶ 1,247:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">Fiber.abort("Goodbye, World!")</syntaxhighlight>
 
=={{header|X86 Assembly}}==
Line 1,236 ⟶ 1,295:
 
=={{header|Zig}}==
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with error handling:
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() !void {
pub fn main() std.fs.File.WriteError!void {
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n");
const stderr = std.io.getStdErr();
// debug messages are also printed to stderr
 
//std.debug.print("Goodbye, World!\n");
try stderr.writeAll("Goodbye, World!\n");
}</syntaxhighlight>
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with no error handling (useful when debugging):
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() void {
// Silently returns if writing to stderr fails.
std.debug.print("Goodbye, World!\n", .{});
}</syntaxhighlight>
 
885

edits