NET:LavishScriptAPI.Delegates.CommandTarget

From Lavish Software Wiki
Revision as of 02:16, 3 December 2006 by Lax (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to navigation Jump to search

Overview

LavishScriptAPI.Delegates.CommandTarget describes the delegate used to implement LavishScript commands through .NET.

Reference Library

Lavish.InnerSpace.dll

Fully Qualified Name

LavishScriptAPI.Delegates.CommandTarget

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 CommandTarget(int argc, uint argvToken)
       {
           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();
       }

See Also