Program termination: Difference between revisions
Content deleted Content added
Puppydrum64 (talk | contribs) m →Nintendo Entertainment System: formatting |
GNU APL example |
||
Line 213:
return 10 -- Number of seconds to the next call of this handler if the applet's still open.
end idle</lang>
=={{header|APL}}==
APL is an interpreted language and does not allow conditionals inside REPL (immediate) expressions, so this must be run within a script.
<lang apl>
#!/usr/local/bin/apl --script --
⍝⍝ GNU APL script
⍝⍝ Usage: errout.apl <code>
⍝⍝
⍝⍝ $ echo $? ## to see exit code
⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
args ← 2↓⎕ARG~'--script' '--' ⍝⍝ strip off script args we don't need
err ← ⍎⊃args[1]
∇main
→(0=err)/ok
error:
'Error! exiting.'
⍎')off 1' ⍝⍝ NOTE: exit code arg was added to )OFF in SVN r1499 Nov 2021
ok:
'No error, continuing...'
⍎')off'
∇
main
</lang>
{{out}}
<pre>
~/GNUAPL$ workspaces/errout.apl 0
No error, continuing...
~/GNUAPL$ echo $?
0
~/GNUAPL$ workspaces/errout.apl 1
Error! exiting.
~/GNUAPL$ echo $?
1
</pre>
=={{header|ARM Assembly}}==
|