COMMAND()

BACK

You can start the ScriptBasic interpreter several ways. The most evident way is to specify the interpreter on the command line:

# scriba test_command.sb arg1 arg2  arg3

You can also start the program using the name of the program:

# test_command.sb arg1 arg2  arg3

This assumes that the script is executable and that the first line is #!/usr/bin/scriba pointing to the interpreter (UNIX). On Windows the file extension .sb should be associated with the interpreter. This is done by the ScriptBasic installer. (Also see the note below.)

Under Windows you can also start the code without specifying the extension:

# test_command arg1 arg2  arg3

You can have the program compiled to executable and you can start the exe with the command

# test_command arg1 arg2  arg3

where test_command now refers to the executable file. In any of these cases the function COMMAND returns the string containning the commal line arguments.

NOTE:

Some versions of the installer has a bug that will prevent passing command-line arguments to a BASIC program when it is started on the command by its name. To check whether your have ScriptBasic corretcly installed try execute the following program:

REM test_command.sb
print COMMAND()
Save the program into the file test_command.sb and type the command:

C:\> test_command arg1 arg2  arg3

If the program prints the arguments, then you are not exposed to this bug. If the program returns without printing anything but a new line you have installed a ScriptBasic version that contains this installer bug.

To correct this bug you should start the registry editor and open the key

HKEY_CLASSES_ROOT\ScriptBasic\shell\command

The default value should be

C:\ScriptBasic\BIN\scriba.exe %1

The actual path to the executable may differ from the listed above. If that is the case you can modify the value to be

C:\ScriptBasic\BIN\scriba.exe %1 %*

You should NOT use the value from this document as listed above, but rather you have to edit the value and append %* after the original value, because it is likely that you have a differet installation path of the interpreter.

BACK