Example #1
0
        private void AddCustomVariable(string cmd)
        {
            GroupCollection groups = Regex.Match(cmd, @"#set\s(?<name>@[a-z,A-z,0-9]+)=?(?<value>.+)?", RegexOptions.Compiled).Groups;
            string          value  = groups["value"].Value;

            if (value.StartsWith("@"))
            {
                value = CustomVariable.GetVariable(value);
            }
            CustomVariable.AddVariable(groups["name"].Value, value);
        }
Example #2
0
 private void ProcessCalcuate(string cmd)
 {
     try
     {
         GroupCollection groups = Regex.Match(cmd, @"#calc\s(?<name>@[a-z,A-z,0-9]+)=(?<value>.+)?", RegexOptions.Compiled).Groups;
         string          value  = groups["value"].Value;
         value = Regex.Replace(value, @"@[a-z,A-z,0-9]+", new MatchEvaluator(new Func <Match, string>(m =>
         {
             return(CustomVariable.GetVariable(m.Value));
         })), RegexOptions.Compiled);
         double result = Util.ParseArithmeticalExpression(value);
         CustomVariable.AddVariable(groups["name"].Value, result.ToString());
     }
     catch (Exception e)
     {
         SendText("#test Error:" + e.Message);
     }
 }