public static string GetValue(string name, bool replace = true) { EVariable a = GetVariable(name); if (a == null) { return(""); } else { if (a.Value.ToString().Contains("{") && a.Value.ToString().Contains("}") && replace) { if (GetValue("varCanBeMethod") == "1") { List <iString> list = new List <iString>(); for (int i = 0; i < a.Value.ToString().Length; i++) { if (a.Value.ToString()[i] == '{') { iString test = new iString() { startIdx = i }; for (int c = test.startIdx; c < a.Value.ToString().Length; c++) { if (a.Value.ToString()[c] == '}') { test.text.Append("}"); test.endIdx = c + 1; break; } test.text.Append(a.Value.ToString()[c]); } i = test.endIdx; list.Add(test); } } foreach (var r in list) { return(a.Value.ToString().Replace(r.text.ToString(), Cmd.Process(r.text.ToString().TrimStart('{').TrimEnd('}')))); } } } return(a.Value.ToString()); } }
private static List <iString> GetMethodsInsideOfStringEx(string result) { List <iString> list = new List <iString>(); if (result.Contains("{") && result.Contains("}")) { for (int i = 0; i < result.Length; i++) { //try //{ // not using {{ }} anymore, use {# } instead // example: // async {#msg 1||2||3||4} if (result[i] == '{' && result[i + 1] != '{') // for {} { iString test = new iString() { startIdx = i, endIdx = -1 }; for (int c = test.startIdx; c < result.Length; c++) { if (result[c] == '}') { test.text.Append("}"); test.endIdx = c + 1; break; } test.text.Append(result[c]); } if (test.endIdx == -1) { throw new Exception("ESCRIPT_ERROR_INVALID_INVOKE"); } i = test.endIdx; list.Add(test); } //} //catch (Exception ex) //{ // Program.Debug(ex.ToString(), ConsoleColor.DarkRed); //} } } return(list); }