Difference between revisions of "COMMAND$"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
imported>Clippy
m
Line 19: Line 19:
: ''Program B'' checks for fullscreen parameter pass in QB64.  
: ''Program B'' checks for fullscreen parameter pass in QB64.  
{{CodeStart}}
{{CodeStart}}
{{Cl|IF}} {{Cl|UCASE$}}({{Cl|LEFT$}}({{Cl|COMMAND$}}, 2)) = "FS" THEN {{Cl|_FULLSCREEN}}  'parameter already uppercase in Qbasic
parameter$ = {{Cl|COMMAND$}}
{{Cl|IF}} {{Cl|UCASE$}}({{Cl|LEFT$}}(parameter$, 2)) = "FS" THEN {{Cl|_FULLSCREEN}}  'parameter already uppercase in Qbasic
{{CodeEnd}}
{{CodeEnd}}



Revision as of 10:02, 10 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.

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


See also:




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