~~Title: OnScriptCommand ~~
The **OnScriptCommand** event is the entry point for an [[:scripting:example_scripts:adding_a_new_internal_command|internal command]] added by a [[:scripting:script_add-ins|script add-in]]. The actual name of the event is defined by the script itself, when the command is added via the **[[..:scripting_objects:scriptinitdata|ScriptInitData]].AddCommand** method - **OnScriptCommand** is merely a placeholder name.
$$ (#)**Method Name:**
$$ OnScriptCommand
$$ (#)**Argument Type:**
$$ **[[..:scripting_objects:scriptcommanddata|ScriptCommandData]]**
$$ (#)**Return Type:**
$$ //bool// or //int//
$$ (#)**Description:**
$$ When a script add-in adds a new internal command using **ScriptInitData.AddCommand**, it specifies the name of its entry point with the **ScriptCommand.method** property. When the internal command is run, Opus will call that method within your script.
The **ScriptCommandData.func** property provides information about the command environment (including any parsed arguments), and the **cmdline** property provides the raw command line that invoked your command.
The return value from this function indicates to Opus whether your function was successful or not and whether it should be called again for the next selected file. If successful, the return code should indicate the number of files consumed by the function - normally this would be `1` which would mean you would be called separately for each file.
^Return value^Meaning^
|-1|Function was successful. All files will be deselected.|
|1|Function was successful. First file will be deselected, and your function will be called again for the next file.|
|True|Function failed. Files will remain selected.|
|False|Same as returning -1.|