Ejemplo n.º 1
0
        public ScriptVariable Get(ScriptExecutionEnvironment environment)
        {
            if (_variable == null)
            {
                environment.Console.Warn("Cannot use indexer for null variable");
                return(null);
            }
            if (_index == null)
            {
                environment.Console.Warn("Cannot use null as indexer");
                return(null);
            }
            ListVariable   list = _variable as ListVariable;
            StringVariable key  = _index as StringVariable;

            if (list != null && key != null)
            {
                return(list[key.Value]);
            }

            int            indexInt = _index.ToInteger();
            ScriptVariable ret;

            if (!_variable.GetIndexedValue(indexInt, out ret))
            {
                environment.Console.Warn(string.Format("Invalid index : {0}", _index.ToString()));
                ret = null;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public override bool FromScriptVariable(MotionProcEnv environment, ScriptVariable variable, ref string errorMessage)
        {
            Sequence.SequenceData parent = this.Parent.Value;

            switch (variable.Type)
            {
            case ScriptVariableType.Number:
                int index = variable.ToInteger();
                if (index < 0 || index >= parent.Values.ColumnCount)
                {
                    errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_IndexOutOfRange + ": " + index.ToString();
                    return(false);
                }
                this.Value = index;
                return(true);

            case ScriptVariableType.String:
                string name   = variable.ToString();
                int    index2 = Array.IndexOf(parent.Values.ColumnNames, name);
                if (index2 == -1)
                {
                    errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_ColumnNameNotFound;
                    return(false);
                }
                this.Value = index2;
                return(true);

            default:
                errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_SpecifyIndexOfColumnOrColumnName;
                return(false);
            }
        }
Ejemplo n.º 3
0
        public override bool FromScriptVariable(TEnvironment environment, ScriptVariable variable, ref string errorMessage)
        {
            if (variable.Type != ScriptVariableType.Number)
            {
                errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_SpecifyInteger;
                return(false);
            }
            int index = variable.ToInteger();

            if (index < 0 || index >= _RadioTexts.Count)
            {
                errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_IndexOutOfRange + ": " + index.ToString();
                return(false);
            }
            this.Value = index;
            return(true);
        }
        public override bool FromScriptVariable(SequenceProcEnv environment, ScriptVariable variable, ref string errorMessage)
        {
            SequenceData parent = environment.SelectedSequence;

            if (this.Parent != null && this.Parent.Value != null)
            {
                parent = this.Parent.Value;
            }
            switch (variable.Type)
            {
            case ScriptVariableType.Number:
                int index = variable.ToInteger();
                if (index < 0 || index >= parent.Values.ColumnCount)
                {
                    errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_IndexOutOfRange + ": " + index.ToString();
                    return(false);
                }
                this.Value = index;
                return(true);

            case ScriptVariableType.String:
                string name   = variable.ToString();
                int    index2 = -1;
                for (int i = 0; i < parent.Values.ColumnNames.Length; i++)
                {
                    if (parent.Values.ColumnNames[i] == name)
                    {
                        index2 = i;
                        break;
                    }
                }
                if (index2 == -1)
                {
                    errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_ColumnNameNotFound;
                    return(false);
                }
                this.Value = index2;
                return(true);

            default:
                errorMessage = MotionDataHandler.Properties.Settings.Default.Msg_SpecifyIndexOfColumnOrColumnName;
                return(false);
            }
        }