COMMAND$ function
Purpose: COMMAND$ returns the command line tail, that is, a character string containing everything typed on the command line after the filename that started the program.
Syntax 1: RetStr$ = COMMAND$ Parameters:
Return Value:
|
Example:
DIM RetStr$ RetStr$ = COMMAND$ PRINT RetStr$
Syntax 2: RetStr$ = COMMAND$(ArgCount%) Parameters:
Return Value:
|
Example: This example uses the BCX translator internally generated 'argc' parameter of the C 'main' function. 'argc' contains the number of arguments on the command line of the executed program.
DIMcmd$DIMi%, tailargs% cmd$=COMMAND$tailargs%=argc-1"Full command tail: [", cmd$,"]""The executable name is [",COMMAND$(0),"]"FORi%=1TOtailargs% cmd$=COMMAND$(i)"Argument", i," is [", cmd$,"]"NEXTi%"Total command tail arguments:", tailargs%
Using COMMAND$ to detect drag and dropped files
COMMAND$ is drag and drop aware and can capture the path and name of a file that is drag and dropped or copied and pasted on to its executable.
The following example will capture the path\filename of any file dropped on it and show a Message Box with, and print to a file, the path\filename of the dropped file.
DIM Filename$ DIM A$ 'Use this to write to Current folder 'Filename$ = CurDir$ &"\TestFile.txt" 'Use this to write to exe folder Filename$ = APPEXEPATH$ &"TestFile.txt" OPEN Filename$ FOR APPEND AS FP1 A$ = COMMAND$ MSGBOX A$ FPRINT FP1, A$ CLOSE FP1
BCX Console Sample Programs using statement function.
S06.bas, S44.bas, S47.bas, S48.bas, S64.bas, S65.bas, S67.bas, S68.bas, S71.bas, S73.bas, S74.bas, S77.bas, S96.bas, S98.bas, S103.bas, S105.bas, S141.bas,