Example #1
0
        public static Variable CreateVariable(string varName, bool system, bool readOnly, bool calculated)
        {
            string varNameLower = varName.ToLower();
            if (_variables.ContainsKey(varNameLower)) throw new Exception("Internal: Variable '" + varName + "' already exists.");

            Variable var = new Variable(varName, system, readOnly, calculated);
            _variables.Add(varNameLower, var);

            if (!Globals.silentMode && !system) Globals.form.WriteLine(HistoryType.Info, "Created variable '" + varName + "'.");

            return var;
        }
Example #2
0
 public Variable Clone()
 {
     Variable var = new Variable(_name, _system, _readOnly);
     var._value = _value.Clone();
     return var;
 }
Example #3
0
        private bool GetSelectedData(out Variable var, out Macro macro)
        {
            if (lstData.SelectedItems.Count != 1)
            {
                _selectTag = "";
                var = null;
                macro = null;
                return false;
            }

            _selectTag = lstData.SelectedItems[0].Tag.ToString();
            if (_selectTag.Length < 2) throw new Exception("Item tag text is too short.");

            string name = _selectTag.Substring(1);
            switch (_selectTag[0])
            {
                case 'v':
                    var = Data.GetVariable(name);
                    macro = null;
                    return true;

                case 'm':
                    macro = Data.GetMacro(name);
                    var = null;
                    return true;

                default:
                    throw new Exception("Item tag does not being with 'v' or 'm'.");
            }
        }