Exemple #1
0
        public override IScriptType Invoke(params IScriptType[] arguments)
        {
            IScriptType v = arguments[0];

            if (v is IScriptString s)
            {
                return(Processor.Factory.Create(s.Value.Length));
            }

            PMWrapper.RaiseError($"Kan inte beräkna längden på värde av typen '{v.GetTypeName()}'.");
            return(Processor.Factory.Null);
        }
Exemple #2
0
        public override IScriptType Invoke(params IScriptType[] arguments)
        {
            IScriptType v = arguments[0];

            if (v is IScriptInteger i)
            {
                if (i.Value < 0)
                {
                    return(Processor.Factory.Create("-0b" + Convert.ToString(-i.Value, 2)));
                }

                return(Processor.Factory.Create("0b" + Convert.ToString(i.Value, 2)));
            }

            PMWrapper.RaiseError($"Kan inte konvertera typen '{v.GetTypeName()}' till binärt!");
            return(Processor.Factory.Null);
        }
Exemple #3
0
        public override IScriptType Invoke(params IScriptType[] arguments)
        {
            IScriptType v = arguments[0];

            switch (v)
            {
            case IScriptInteger i:
                return(Processor.Factory.Create(i.Value));

            case IScriptDouble d:
                return(Processor.Factory.Create(Math.Round(d.Value)));

            default:
                PMWrapper.RaiseError($"Kan inte avrunda värde av typen '{v.GetTypeName()}'.");
                return(Processor.Factory.Null);
            }
        }