From QB64 Wiki
Revision as of 22:49, 9 October 2010 by imported>Clippy
Jump to navigation Jump to search

The COMMAND$ function returns the DOS commandline arguments passed when a program is run.

Syntax: variable$ = COMMAND$

  • The string return value is any parameter following the filename in a RUN or command line statement.
  • Qbasic returns uppercase STRING parameters no matter what case they were sent originally.
  • QB64 does not require or return all uppercase values so keep that fact in mind when checking parameters passed!
  • Useful when the programmer wants to add options to the command line of a program for later use by another program.
  • COMMAND$ was not available in QuickBasic versions below 4.0

Example: Program A runs a program with a parameter following the filename:

RUN "ProgramB.exe fs"

Program B checks for fullscreen parameter pass in QB64.

IF UCASE$(LEFT$(COMMAND$, 2)) = "FS" THEN _FULLSCREEN 'parameter already uppercase in Qbasic

See also:

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page