Difference between revisions of "NET:LavishScriptAPI.Delegates.CommandTarget"

From Lavish Software Wiki
Jump to navigation Jump to search
 
Line 24: Line 24:
 
== Examples ==
 
== Examples ==
 
=== C# ===
 
=== 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.
+
; 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 InnerSpaceAPI;
using LavishScriptAPI;
+
  using LavishScriptAPI;
using LavishVMAPI;
+
  using LavishVMAPI;
 
+
        static public int MyCommand(string[] args)
+
        static public int MyCommand(string[] args)
        {
+
        {
    using (new FrameLock(true))
+
    using (new FrameLock(true))
    {
+
    {
              InnerSpace.Echo("MyCommand ("+args.Length.ToString()+" args)");
+
                InnerSpace.Echo("MyCommand ("+args.Length.ToString()+" args)");
              for (int i = 0; i < args.Length; i++)
+
                for (int i = 0; i < args.Length; i++)
              {
+
                {
                  InnerSpace.Echo(i.ToString() + ": " + args[i]);
+
                    InnerSpace.Echo(i.ToString() + ": " + args[i]);
              }
+
                }
            }
+
            }
        }
+
        }
  
 
== See Also ==
 
== See Also ==

Latest revision as of 16:37, 7 March 2008

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] string[] args);

Parameters

  • [In] string[] args
The individual parameters passed to this command. The first parameter (args[0]) 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;

        static public int MyCommand(string[] args)
        {
	    using (new FrameLock(true))
	    {
               InnerSpace.Echo("MyCommand ("+args.Length.ToString()+" args)");
               for (int i = 0; i < args.Length; i++)
               {
                   InnerSpace.Echo(i.ToString() + ": " + args[i]);
               }
            }
        }

See Also