BB___CommandLine

=CommandLine$= toc

Description
> If you use parameters or switches in a command line statement, those parameters will be contained in the special variable CommandLine$. This is useful when running a .tkn file under the runtime engine. To check for the parameters, you inspect the CommandLine$ in your called program for the existence of any switches or parameters.

Usage
From the JB Help file, here is an example that will fill the background of a graphics window with the color "red" when opening. Notice how the CommandLine$ is inpected with the **instr** function to see if it contains the parameter "red". code format="lb" 'commandlinetest1.bas ' 'program to be tokenized 'to commandlinetest1.tkn 'and used with runtime engine 'commandlinetest1.exe

open "CommandLine$ Test" for graphics as #win print #win, "trapclose [quit]"

'convert to lower case for evaluation: CommandLine$ = lower$(CommandLine$)

if instr(CommandLine$, "red") > 0 then print #win, "fill red; flush" end if

wait

[quit] close #win : end code

Syntax
To call this program, you might use this syntax: or

Hints
>> code format="lb" if word$(CommandLine$, 1) = "red" then print #win, "fill red; flush" end if code >> code format="lb" first$ = word$(CommandLine$, 1) firstVal = val(first$) code > The CommandLine$ could contain a filename which the program would open and load into a texteditor. The CommandLine$ could contain numbers to be used in calculations. As in the examples above, it could contain colors that determine the look of a window.
 * //**Multiple Parameters.**//Of course, your command line could contain more than one parameter. If so, you can use the WORD$ function to extract each word. For example:
 * //**Parsing Numbers.**// The information in CommandLine$ can be anything that could be in a string. If you need to extract a number from the string, use the val function:
 * //**Suggestions for Use.**// From the Help file once again:

Useful Functions
code format="lb" Place a useful function using this command here code