1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 10:01:21 +00:00
qb64/internal/help/_COMMANDCOUNT.txt

31 lines
1.2 KiB
Plaintext
Raw Normal View History

2016-03-18 11:36:04 +00:00
{{DISPLAYTITLE:_COMMANDCOUNT}}
The [[_COMMANDCOUNT]] function returns the number or arguments passed from the command line to the [[COMMAND$]] function.
{{PageSyntax}}
2017-10-10 14:55:21 +00:00
:{{Parameter|result&}} = [[_COMMANDCOUNT]]
2016-03-18 11:36:04 +00:00
{{PageDescription}}
* The function returns the number of arguments passed from the command line to a program when it's executed.
* Arguments are spaced as separate numerical or text values. Spaced text inside of quotes is considered as one argument.
2017-10-10 14:55:21 +00:00
* In C, this function would generally be regarded as 'argc' when the main program is defined as the following: '''int main(int argc, char *argv[])'''
2016-03-18 11:36:04 +00:00
2017-10-10 14:55:21 +00:00
{{PageExamples}}
2016-03-18 11:36:04 +00:00
''Example:'' The code below gets the number of parameters passed to our program from the command line with _COMMANDCOUNT:
{{CodeStart}}limit = {{Cl|_COMMANDCOUNT}}
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} limit
{{Cl|PRINT}} {{Cl|COMMAND$}}(i)
{{Cl|NEXT}}
{{CodeEnd}}
2019-04-15 01:15:33 +00:00
: ''Explanation:'' If we start ''ThisProgram.exe'' from the command window with '''ThisProgram -l "loadfile.txt" -s "savefile.txt"''', the _COMMANDCOUNT would be 4, "-l", "loadfile.txt", "-s", "savefile.txt" command arguments passed to the program, which we could then read separately with COMMAND$(n).
2016-03-18 11:36:04 +00:00
{{PageSeeAlso}}
* [[COMMAND$]]
* [[SHELL]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}