NET:LavishScriptAPI.Delegates.CommandTarget
Jump to navigation
Jump to search
Contents
Overview
LavishScriptAPI.Delegates.CommandTarget describes the delegate used to implement LavishScript commands through .NET.
Reference Library
Fully Qualified Name
- LavishScriptAPI.Delegates.CommandTarget
- LavishScriptAPI namespace
- Delegates namespace
- CommandTarget delegate
- Delegates namespace
Declaration
public delegate int CommandTarget([In] int argc, [In] uint argvToken);
Parameters
- [In] int argc
- The count of arguments passed to this function. There will always be at least 1, the name of the command (modelled after C console program design).
- [In] uint argvToken
- The array of strings passed to this function (char *argv[]). Because the C++ to managed call cannot marshal this properly, the parameter is passed as a token in the form of a uint, and individual parameters can be retrieved with InnerSpace.GetArg. The first parameter is always the name of the command (modelled after C console program design).
Return Value
- int
- The command's return value. A negative value indicates a "fatal" error, which would end a LavishScript script. Any further return value specialization is command-specific.
Examples
C#
- Simple command that will echo each individual argument in the form #=value. This example does not show adding the command to LavishScript or later removing the command.
using InnerSpaceAPI; using LavishScriptAPI; using LavishVMAPI;
LavishScriptAPI.Delegates.CommandTarget CMDdel_MyCommand = CMD_MyCommand; static public int MyCommand(int argc, uint argv) { Frame.Lock(); /* ensure that the command gets executed in one frame. if executed from the main thread, it will anyway. */ for (uint arg = 0; arg < argc; arg++) { InnerSpace.Echo(arg.ToString() + "=" + InnerSpace.GetArg<string>(arg, argv)); } Frame.Unlock(); }