fCraft.SimpleParser.PreparseAssignment C# (CSharp) Method

PreparseAssignment() public static method

public static PreparseAssignment ( string &assignmentFunction ) : string
assignmentFunction string
return string
        public static string PreparseAssignment( ref string assignmentFunction )
        {
            int pos = 0;
            string varName = ReadTerm( assignmentFunction, ref pos );
            string ass = ReadTerm( assignmentFunction, ref pos );
            if ( ass.Length > 1 || ass[0] != '=' )
                throw new ArgumentException( "the expression is not an assignment (i.e. not like z=...)" );
            assignmentFunction = assignmentFunction.Substring( pos );
            return varName;
        }

Usage Example

        public static void SetParametrization(Player p, Command cmd)
        {
            string strFunc = cmd.Next();

            if (string.IsNullOrWhiteSpace(strFunc))
            {
                p.Message("Error: empty parametrization expression");
                return;
            }
            if (strFunc.Length < 3)
            {
                p.Message("Error: expression is too short (should be like x=f(t,u,v))");
                return;
            }

            strFunc = strFunc.ToLower();

            try
            {
                string coordVar = SimpleParser.PreparseAssignment(ref strFunc);
                CheckCoordVar(coordVar);

                Expression expression = SimpleParser.Parse(strFunc, new string[] { "t", "u", "v" });

                GetPlayerParametrizationCoordsStorage(p)[VarNameToIdx(coordVar[0])] = expression;
            }
            catch (Exception e)
            {
                p.Message("Error: " + e.Message);
            }
        }
All Usage Examples Of fCraft.SimpleParser::PreparseAssignment