Exemplo n.º 1
0
        public static void SetVariable(string name, string value, List <string> options = null)
        {
            if (value == null)
            {
                value = "null";
            }
            if (value.Length == 0)
            {
                value = "null";
            }
            EVariable e = GetVariable(name);

            if (e == null)
            {
                EVariable variable = new EVariable(name, value, options);
                VarList.Add(variable);
            }
            else
            {
                if (e.Options.Contains("ReadOnly"))
                {
                    throw new Exception("ESCRIPT_ERROR_EDIT_READONLY_VARIABLE");
                }
                e.Edit(value, options);
            }
        }
Exemplo n.º 2
0
        public static object MethodCleanup(string MethodName)
        {
            List <EVariable> removeList = new List <EVariable>();

            for (int idx = 0; idx < Variables.VarList.Count; idx++)
            {
                EVariable var = Variables.VarList[idx];

                for (int optionIdx = 0; optionIdx < var.Options.Count; optionIdx++)
                {
                    string option = var.Options[optionIdx];
                    if (GlobalVars.RemoveDirtFromString(option) == "Method=" + GlobalVars.RemoveDirtFromString(MethodName))
                    {
                        removeList.Add(var);
                    }
                }
            }

            foreach (var var in removeList)
            {
                Program.Debug("Removing " + var.Name + " because of " + MethodName + " cleanup");
                Variables.Remove(var);
            }

            return(1);
        }
Exemplo n.º 3
0
        public static object GetValueObject(string name)
        {
            EVariable a = GetVariable(name);

            if (a == null)
            {
                return("");
            }
            else
            {
                return(a.Value);
            }
        }
Exemplo n.º 4
0
        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());
            }
        }
Exemplo n.º 5
0
 public static object Remove(EVariable v, bool force = false)
 {
     if (v != null)
     {
         if (!force)
         {
             if (v.Options.Contains("ESCRIPT"))
             {
                 return("ESCRIPT_ERROR_REMOVE_PROTECTED_VARIABLE");
             }
         }
         VarList.Remove(v);
         return(1);
     }
     return("ESCRIPT_ERROR_VARIABLE_NOT_FOUND");
 }
Exemplo n.º 6
0
        public static void SetVariableObject(string name, object value, List <string> options = null)
        {
            if (value == null)
            {
                value = "";
            }
            EVariable e = GetVariable(name);

            if (e == null)
            {
                EVariable variable = new EVariable(name, value, options);
                if (options != null)
                {
                    variable.Options = options;
                }
                VarList.Add(variable);
            }
            else
            {
                e.Edit(value);
            }
        }
Exemplo n.º 7
0
        public static object Remove(string name, bool force = false)
        {
            EVariable v = GetVariable(name);

            return(Remove(v, force));
        }