Command-line arguments: Difference between revisions

Content added Content deleted
No edit summary
m (→‎{{header|TXR}}: Drop @(do ...))
Line 1,665: Line 1,665:
Here is an example program which requires exactly three arguments. Note how <code>ldiff</code> is used to compute the arguments that are processed by TXR (the interpreter name, any special arguments and script name), to print an accurate usage message.
Here is an example program which requires exactly three arguments. Note how <code>ldiff</code> is used to compute the arguments that are processed by TXR (the interpreter name, any special arguments and script name), to print an accurate usage message.


<lang txr>@(do
<lang txrlisp>(tree-case *args*
((a b c) (put-line "got three args, thanks!"))
(tree-case *args*
((a b c) (put-line "got three args, thanks!"))
(else (put-line `usage: @(ldiff *full-args* *args*) <arg1> <arg2> <arg3>`)))</lang>
(else (put-line `usage: @(ldiff *full-args* *args*) <arg1> <arg2> <arg3>`))))</lang>
{{out}}
{{out}}
<pre>$ txr command-line-args.txr 1 2
<pre>$ txr command-line-args.txr 1 2