Creating RAPTOR Plugins

RAPTOR checks both the folder where the RAPTOR file is located and the folder where raptor.exe is located for DLLs that contain additional procedures and functions.  RAPTOR will automatically add these procedures and functions to the suggestions list and treats them as if they were part of the RAPTOR language.

To create RAPTOR plugins, simply name a C# DLL (other .NET languages may also be used, but this has primarily been tested with C#) in the form:

plugin*.dll (e.g. Plugins_Playsound.dll)

This should contain a type with public static methods that will be available to RAPTOR programs.  Use private, protected or non-static methods for things you don't want exported to RAPTOR.  Parameters may be of the following types:

Allowable return types are:

Types may be passed as "ref"; however, "ref int", "ref float" will not compile (use "ref double" instead). 

Other items of note: 

Here is a small plugin by Prof. Timothy D. Ellis (Schoolcraft College). It is useful for displaying currency, percentages, and sorting arrays of numbers

using System;

namespace plugin_test
{
   public class Addins
   {
      public Addins()
      {
      }
      public static string Get_Currency(double arg)
      {
         return arg.ToString("C");
      }
      public static string Get_Percent(double arg)
      {
         return arg.ToString("p");
      }
      public static string Get_Number(double arg)
      {
         return arg.ToString("N");
      }
      public static string Get_FixedPoint(double arg)
      {
         return arg.ToString("F");
      }
      public static void Sort_Array(int[] arg)
      {
         Array.Sort(arg);

      }
   }
}

Here is a portion of the plugin used in the Tic_Tac_Toe sample:

using System;
using dotnetgraphlibrary;

namespace plugin_tic_tac_toe
{
    public class Addins
    {
        public Addins()
        {

        }
        private static int winner = 0;
        public static int Who_Won(int[][] Board)
        {
            if (Game_Over(Board))
            {
                return winner;
            }
            else
            {
                return 0;
            }
        }

        public static int Get_Row(int x, int y)
        {
            return y/100+1;
        }

        public static void Draw_Board(int[][] Board)
        {
            if ((Board.GetLength(0)!=3) ||
                (Board[0].GetLength(0)!=3))
            {
                throw new System.Exception("Board is not 3x3");
            }
            dotnetgraph.Clear_Window(Color_Type.White);
            dotnetgraph.Draw_Box(99,1,101,300,Color_Type.Black,true);
            dotnetgraph.Draw_Box(199,1,201,300,Color_Type.Black,true);
            dotnetgraph.Draw_Box(1,99,300,101,Color_Type.Black,true);
            dotnetgraph.Draw_Box(1,199,300,201,Color_Type.Black,true);
            for (int j=0; j<=2; j++)
            {
                for (int i=0; i<=2; i++)
                {
                    if (Board[j][i]==1)
                    {
                        dotnetgraph.Draw_Line(
                            1+i*100,100+j*100,100+i*100,1+j*100,Color_Type.Green);
                        dotnetgraph.Draw_Line(
                            1+i*100,1+j*100,100+i*100,100+j*100,Color_Type.Green);
                    }
                    else if (Board[j][i]==2)
                    {
                        dotnetgraph.Draw_Circle(50+i*100,50+j*100,
                            40,Color_Type.Red,false);
                    }
                }
            }
        }

    ...


    }//addins
}//namespace