QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _COMMANDCOUNT function returns the number or arguments passed from the command line to the COMMAND$ function.

Syntax

result& = _COMMANDCOUNT

Description

Example(s)

The code below gets the number of parameters passed to our program from the command line with _COMMANDCOUNT:


limit = _COMMANDCOUNT
FOR i = 1 TO limit
    PRINT COMMAND$(i)
NEXT

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).

See Also