Difference between revisions of "COMMAND$"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
Line 1: Line 1:
The '''COMMAND$''' function returns the DOS commandline arguments passed when a program was run.
The '''COMMAND$''' function returns the DOS commandline arguments passed when a program is run.




Line 6: Line 6:




* Return is a [[STRING]] with all arguments in uppercase no matter what case they were originally.
* The [[STRING|string]] return value is any parameter following the filename in a [[RUN]] or command line statement.
* Useful when the programmer wants to add options to the command line of a program for later use by another.
* Qbasic returns [[UCASE$|uppercase]] [[STRING]] parameters no matter what case they were sent originally.  
* COMMAND$ is not available in QuickBasic versions below 4.0
* '''QB64''' does not '''require or return all [[UCASE$|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 [[RUN|runs]] a program with a parameter following the filename:
{{CodeStart}}
{{Cl|RUN}} "ProgramB.exe fs"
{{CodeEnd}}
: ''Program B'' checks for fullscreen parameter pass in QB64.
{{CodeStart}}
{{Cl|IF}} {{Cl|UCASE$}}({{Cl|LEFT$}}({{Cl|COMMAND$}}, 2)) = "FS" THEN {{Cl|_FULLSCREEN}}  'parameter already uppercase in Qbasic
{{CodeEnd}}




Line 14: Line 26:
''See also:''  
''See also:''  


[[SHELL]], [[RUN]]
* [[SHELL]], [[RUN]]
 
* [[UCASE$]], [[LCASE$]]






{{PageNavigation}}
{{PageNavigation}}

Revision as of 22:49, 9 October 2010

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:




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