Command-line arguments: Difference between revisions
Content added Content deleted
No edit summary |
(added powerbasic and visual basic; changed realbasic's lang tag to vb; minor edits to basic; alphabetized list) |
||
Line 76: | Line 76: | ||
{{works with|FreeBASIC}} |
{{works with|FreeBASIC}} |
||
FreeBASIC supplies three ways to retrieve the arguments: <code>COMMAND$</code> (which works identically to QuickBASIC's <code>COMMAND$</code>), <code>COMMAND$()</code> (a string array which works like C's <code>argv[]</code>), and <code>__FB_ARGV__</code> (an array of pointers which works even more like C's <code>argv[]</code>). |
FreeBASIC supplies three ways to retrieve the arguments: <code>COMMAND$</code> (which works identically to QuickBASIC's <code>COMMAND$</code>), <code>COMMAND$()</code> (a string array which works like [[#C|C]]'s <code>argv[]</code>), and <code>__FB_ARGV__</code> (an array of pointers which works even more like C's <code>argv[]</code>) and __FB_ARGC__ (which works like C's <code>argc</code>). |
||
<lang freebasic>DIM i AS INTEGER |
<lang freebasic>DIM i AS INTEGER |
||
Line 104: | Line 104: | ||
arg 2 = '2' |
arg 2 = '2' |
||
arg 3 = '3' |
arg 3 = '3' |
||
See also: [[Command Line Arguments#RapidQ|RapidQ]] |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
Line 223: | Line 221: | ||
} |
} |
||
}</lang> |
}</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
Line 241: | Line 246: | ||
All of these return a list of strings. |
All of these return a list of strings. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|D}}== |
=={{header|D}}== |
||
Line 598: | Line 596: | ||
20 |
20 |
||
</pre> |
</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
Line 621: | Line 609: | ||
} |
} |
||
</lang> |
</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
Line 732: | Line 730: | ||
$second_arg = $argv[2]; |
$second_arg = $argv[2]; |
||
?></lang> |
?></lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
Line 774: | Line 760: | ||
Got 'c': alpha beta |
Got 'c': alpha beta |
||
Got 'h': gamma</pre> |
Got 'h': gamma</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Pop11}}== |
=={{header|Pop11}}== |
||
Line 783: | Line 781: | ||
printf(arg, '->%s<-\n'); |
printf(arg, '->%s<-\n'); |
||
endfor;</lang> |
endfor;</lang> |
||
=={{header|PowerBASIC}}== |
|||
For versions of PowerBASIC prior to [[PB/Win]] 9 and [[PB/CC]] 5, the only option available is identical to the one used by [[#BASIC|QuickBASIC]] above: |
|||
<lang powerbasic>? "args: '"; COMMAND$; "'"</lang> |
|||
Current versions of PowerBASIC (with the likely exception of [[PB/DOS]]) include <code>COMMAND$()</code> that works similarly to [[FreeBASIC]]'s <code>COMMAND$()</code>, except that you can't retrieve the application's name: |
|||
<lang powerbasic>'these two both return ALL args |
|||
? COMMAND$ |
|||
? COMMAND$(0) |
|||
DO WHILE(LEN(COMMAND$(i))) |
|||
PRINT "The argument "; i; " is "; COMMAND$(i) |
|||
i = i + 1 |
|||
LOOP</lang> |
|||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
Line 854: | Line 866: | ||
=={{header|REALbasic}}== |
=={{header|REALbasic}}== |
||
⚫ | |||
<lang realbasic> |
|||
⚫ | |||
For each arg As String In args |
For each arg As String In args |
||
Stdout.WriteLine(arg) |
Stdout.WriteLine(arg) |
||
Line 861: | Line 872: | ||
End Function</lang> |
End Function</lang> |
||
Output (given arguments: ''--foo !bar "bat bang"''): |
Output (given arguments: ''--foo !bar "bat bang"''): |
||
⚫ | |||
<pre> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 1,077: | Line 1,086: | ||
./args.v a b c |
./args.v a b c |
||
=[args.v a b c]</lang> |
=[args.v a b c]</lang> |
||
=={{header|Visual Basic}}== |
|||
Like [[#BASIC|Qbasic]], Visual Basic returns all of the args in the built-in variable <code>Command$</code>: |
|||
<lang vb>Sub Main |
|||
MsgBox Command$ |
|||
End Sub</lang> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |