Example #1
0
        protected override void Executed(Params args, IConsoleOutput target)
        {
            ScriptTargetWrapper stw = target as ScriptTargetWrapper;

            if (Boolean.Evaluate(args))
            {
                stw.Session.Scope.Push(new ScopeLoopPoint(ignoreLines: false, loopPoint: stw.Session.Index, target: stw));
            }
            else
            {
                stw.Session.Scope.Push(new ScopeLoopPoint(ignoreLines: true, target: stw));
            }
        }
Example #2
0
        protected override void Executed(Params args, IConsoleOutput target)
        {
            if (args.Last() != "{")
            {
                ThrowSyntaxError(this, args, ErrorCode.NOT_ENOUGH_ARGUMENTS);
            }

            ScriptTargetWrapper stw = target as ScriptTargetWrapper;

            //If we are currently in a loop
            if (EndBlock.LastPoppedEnumerator != null)
            {
                //If the loop is not finished, forward it
                if (EndBlock.LastPoppedEnumerator.MoveNext())
                {
                    stw.Session.Scope.Push(new ScopeLoopPoint(EndBlock.LastPoppedEnumerator, stw.Session.Index, stw));
                    stw.Session.Scope.Peek().Locals.Set(args[0], EndBlock.LastPoppedEnumerator.Current);
                }

                //If the loop is finished, ignore lines
                else
                {
                    stw.Session.Scope.Push(new ScopeLoopPoint(ignoreLines: true, target: stw));
                }

                EndBlock.LastPoppedEnumerator = null;
            }

            //If we are starting a loop
            else
            {
                IEnumerator <string> _;

                //If we are looping over a list
                if (args[2].StartsWith("["))
                {
                    _ = ConConverter.GetList(args[2]).GetEnumerator();
                }

                //If we are looping over an array
                else
                {                       //take to prevent getting the {
                    _ = args.Skip(2).Take(args.Count - 3).GetEnumerator();
                }

                //Push the enumerator (yes we take the recursion way, shouldn't be a problem)
                EndBlock.LastPoppedEnumerator = _;
                Executed(args, target);
            }
        }