public string ParseParenthesis(string command) { command = command.Trim(); if (command.Length < 1) { return(command); } if (command.Contains(eval_open)) // there's a dvar needs to be evaluated { //bruteforce int start = command.IndexOf(eval_open); int end = start; for (int i = start; i < command.Length && i >= 0; i++) { if (command[i] == eval_open) { start = i; } else if (command[i] == eval_close) { end = i; string left = command.Substring(0, start); string right = command.Substring(end + 1); string mid = EvaluateString(command.Substring(start + 1, end - start - 1)); command = left + Ram.GetValue(mid) + right; start = command.IndexOf(eval_open); i = start; } } } return(command); }
void s_inc(IList <string> args) { if (args.Count == 2) { Ram.Add(args[1], (float.Parse(Ram.GetValue(args[1])) + 1).ToString()); } else if (args.Count == 3) { Ram.Add(args[1], (float.Parse(Ram.GetValue(args[1])) + float.Parse(args[2])).ToString()); } else { throw new Exception("Error in ~inc"); } }