protected override ScriptVariable CalculateInternal(ScriptExecutionEnvironment env)
        {
            ScriptVariable operand = this.Operand.Calculate(env);

            switch (this.Operator)
            {
            case OperatorType.Minus:
                return(new NumberVariable(-operand.ToNumber()));

            case OperatorType.Plus:
                return(new NumberVariable(operand.ToNumber()));

            case OperatorType.Not:
                return(new BooleanVariable(!operand.ToBoolean()));
            }
            throw new NotImplementedException(this.Operator.ToString());
        }
Example #2
0
        public ScriptVariable Call(IList <ScriptVariable> args, ScriptConsole console)
        {
            ScriptVariable arg = null;

            if (args.Count >= 1)
            {
                arg = args[0];
            }
            if (arg == null)
            {
                return(null);
            }
            return(new NumberVariable(arg.ToNumber()));
        }
Example #3
0
        public override bool FromScriptVariable(TEnvironment environment, ScriptVariable variable, ref string errorMessage)
        {
            switch (variable.Type)
            {
            case ScriptVariableType.Number:
                decimal value = variable.ToNumber();
                if (value < this.Minimum || value > this.Maximum)
                {
                    errorMessage = global::MotionDataHandler.Properties.Settings.Default.Msg_ValueOutOfRange + ": " + value.ToString();
                    return(false);
                }
                this.Value = value;
                return(true);

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