Exemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////

        #region IState Members (Optional)
        /// <summary>
        /// Initialize the plugin and/or setup any needed state.
        /// </summary>
        /// <param name="interpreter">
        /// The interpreter context we are executing in.
        /// </param>
        /// <param name="clientData">
        /// The extra data supplied when this plugin was initially created, if
        /// any.
        /// </param>
        /// <param name="result">
        /// Upon success, this may contain an informational message.
        /// Upon failure, this must contain an appropriate error message.
        /// </param>
        /// <returns>
        /// ReturnCode.Ok on success, ReturnCode.Error on failure.
        /// </returns>
        public override ReturnCode Initialize(
            Interpreter interpreter, /* in */
            IClientData clientData,  /* in */
            ref Result result        /* out */
            )
        {
            if (interpreter == null)
            {
                //
                // NOTE: We require a valid interpreter context.  Most plugins
                //       will want to do this because it is a fairly standard
                //       safety check (HIGHLY RECOMMENDED).
                //
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }

            IFunction function = new Class8(new FunctionData(
                                                typeof(Class8).Name, null, null, clientData, null,
                                                1, null, Utility.GetFunctionFlags(typeof(Class8)),
                                                this, functionToken));

            if (interpreter.AddFunction(function, clientData,
                                        ref functionToken, ref result) == ReturnCode.Ok)
            {
                return(base.Initialize(interpreter, clientData, ref result));
            }

            return(ReturnCode.Error);
        }
Exemplo n.º 2
0
 public static void InstallAll(Interpreter interpreter)
 {
     // TODO add OpenSBP math functions here.
     // Any new function that's added here must also have its keyword added to the
     // function list at the top of Lexer.cs!
     interpreter.AddFunction("str", Str);
     interpreter.AddFunction("num", Num);
     interpreter.AddFunction("abs", Abs);
     interpreter.AddFunction("min", Min);
     interpreter.AddFunction("max", Max);
     interpreter.AddFunction("not", Not);
     interpreter.AddFunction("msgbox", MsgBox);
 }
Exemplo n.º 3
0
        public static void InstallAll(Interpreter interpreter)
        {
            interpreter.AddFunction("TOSTR", ToStr);
            interpreter.AddFunction("TODIM", ToDim);
            interpreter.AddFunction("TONUM", ToNum);

            interpreter.AddFunction("ISSTR", IsStr);
            interpreter.AddFunction("ISDIM", IsDim);
            interpreter.AddFunction("ISNUM", IsNum);

            interpreter.AddFunction("ABS", Abs);
            interpreter.AddFunction("NEG", Neg);
            interpreter.AddFunction("RAND", Rand);
            interpreter.AddFunction("MIN", Min);
            interpreter.AddFunction("MAX", Max);

            interpreter.AddFunction("SIN", Sin);
            interpreter.AddFunction("COS", Cos);
            interpreter.AddFunction("TAN", Tan);
            interpreter.AddFunction("SQRT", Sqrt);
            interpreter.AddFunction("SIGN", Sign);

            interpreter.AddFunction("ROUNDUP", RoundUp);
            interpreter.AddFunction("ROUNDDOWN", RoundDown);
            interpreter.AddFunction("ROUND", Round);

            interpreter.AddFunction("ISNAN", IsNaN);

            interpreter.AddFunction("LEN", Len);
            interpreter.AddFunction("TOUPPER", ToUpper);
            interpreter.AddFunction("TOLOWER", ToLower);
            interpreter.AddFunction("TRIM", Trim);

            interpreter.AddFunction("TRIMSTART", TrimStart);
            interpreter.AddFunction("TRIMEND", TrimEnd);
            interpreter.AddFunction("LEFT", Left);
            interpreter.AddFunction("RIGHT", Right);
            interpreter.AddFunction("SUBSTRING", SubString);
            interpreter.AddFunction("REPEAT", Repeat);
            interpreter.AddFunction("INSTR", InStr);
            interpreter.AddFunction("REPLACE", Replace);

            interpreter.AddFunction("SHUFFLE", Shuffle);
            interpreter.AddFunction("COUNT", Count);
            interpreter.AddFunction("UNIQUE", Unique);
            interpreter.AddFunction("UNION", Union);
            interpreter.AddFunction("CONCAT", Concat);
            interpreter.AddFunction("ASCENDING", Ascending);
            interpreter.AddFunction("DESCENDING", Descending);
            interpreter.AddFunction("REVERSE", Reverse);

            interpreter.AddFunction("SOUND", Sound);
            interpreter.AddFunction("SOUNDQUE", SoundQue);
            interpreter.AddFunction("SOUNDQUECLEAR", SoundQueClear);
            interpreter.AddFunction("SOUNDSIGNAL", SoundSignal);

            interpreter.AddFunction("TIMER", Timer);

            //New Functions ver 1.1
            interpreter.AddFunction("DIST", Dist);
            interpreter.AddFunction("SUM", Sum);
            interpreter.AddFunction("LERP", Lerp);
            interpreter.AddFunction("AVG", Avg);
        }