예제 #1
0
		public PassiveExpression Prout(PassiveExpression expression)
		{
			if (expression == null)
				return null;

			//Console.WriteLine("{0}", expression.ToStringBuilder(0));
			ScriptThread.App.WriteLine(expression.ToStringBuilder(0).ToString());

			return null;
		}
예제 #2
0
        public PassiveExpression Prout(PassiveExpression expression)
        {
            if (expression == null)
            {
                return(null);
            }

            ScriptThread.App.Console.WriteLine(expression.ToStringBuilder(0).ToString());
            return(null);
        }
예제 #3
0
        public static PassiveExpression _Prout(PassiveExpression expression)
        {
            if (expression == null)
            {
                return(null);
            }

            Console.WriteLine("{0}", expression.ToStringBuilder(0));

            return(null);
        }
예제 #4
0
        public PassiveExpression Explode(PassiveExpression expression)
        {
            // convert expression to string and remove trailing space, if any
            var sb = expression.ToStringBuilder(0);

            if (sb.Length > 0 && sb[sb.Length - 1] == ' ')
            {
                sb.Length -= 1;
            }

            return(PassiveExpression.Build(sb.ToString().ToCharArray()));
        }
예제 #5
0
        public PassiveExpression Prout(PassiveExpression expression)
        {
            if (expression == null)
            {
                return(null);
            }

            //Console.WriteLine("{0}", expression.ToStringBuilder(0));
            EvaluationContext.Write(expression.ToStringBuilder(0).ToString() + Environment.NewLine);

            return(null);
        }
예제 #6
0
        // Standard RTL routines

        public PassiveExpression Print(PassiveExpression expression)
        {
            if (expression == null)
            {
                return(null);
            }

            //Console.WriteLine("{0}", expression.ToStringBuilder(0));
            ScriptThread.App.WriteLine(expression.ToStringBuilder(0).ToString());

            return(expression);
        }
예제 #7
0
        public PassiveExpression Open(PassiveExpression expression)
        {
            // <Open s.Mode s.D e.File-name>
            if (expression == null || expression.Count < 1)
            {
                throw new ArgumentNullException("s.Mode");
            }
            else if (expression.Count < 2)
            {
                throw new ArgumentNullException("s.D");
            }

            string mode     = expression[0].ToString().ToUpper();
            string handle   = expression[1].ToString();
            string fileName = string.Format("refal{0}.dat", handle);

            // fileName can be omitted
            if (expression.Count > 2)
            {
                fileName = expression.ToStringBuilder(2).ToString();
            }

            // R - read, W - write, A - append
            if (mode.StartsWith("R"))
            {
                OpenFiles[handle] = new StreamReader(File.OpenRead(fileName));
            }
            else if (mode.StartsWith("W"))
            {
                OpenFiles[handle] = new StreamWriter(File.Create(fileName));
            }
            else if (mode.StartsWith("A"))
            {
                OpenFiles[handle] = File.AppendText(fileName);
            }
            else
            {
                throw new NotSupportedException("Bad file open mode: " + mode + " (R, W, or A expected)");
            }

            // AFAIK, Open don't return anything
            return(null);
        }
예제 #8
0
        public PassiveExpression Put(PassiveExpression expression)
        {
            if (expression == null || expression.IsEmpty)
            {
                return(Prout(expression));
            }

            string       handle = expression[0].ToString();
            StreamWriter sw     = OpenFiles[handle] as StreamWriter;

            if (sw == null)
            {
                return(Prout(expression));
            }

            sw.WriteLine("{0}", expression.ToStringBuilder(1));

            PassiveExpression result = PassiveExpression.Build(expression);

            result.Remove(result[0]);
            return(result);
        }
예제 #9
0
		public PassiveExpression Open(PassiveExpression expression)
		{
			// <Open s.Mode s.D e.File-name>
			if (expression == null || expression.Count < 1)
				throw new ArgumentNullException("s.Mode");
			else if (expression.Count < 2)
				throw new ArgumentNullException("s.D");

			string mode = expression[0].ToString().ToUpper();
			string handle = expression[1].ToString();
			string fileName = string.Format("refal{0}.dat", handle);

			// fileName can be omitted
			if (expression.Count > 2)
			{
				fileName = expression.ToStringBuilder(2).ToString();
			}

			// R - read, W - write, A - append
			if (mode.StartsWith("R"))
			{
				OpenFiles[handle] = new StreamReader(File.OpenRead(fileName));
			}
			else if (mode.StartsWith("W"))
			{
				OpenFiles[handle] = new StreamWriter(File.Create(fileName));
			}
			else if (mode.StartsWith("A"))
			{
				OpenFiles[handle] = File.AppendText(fileName);
			}
			else
			{
				throw new NotSupportedException("Bad file open mode: " + mode + " (R, W, or A expected)");
			}

			// AFAIK, Open don't return anything
			return null;
		}
예제 #10
0
		public PassiveExpression Explode(PassiveExpression expression)
		{
			// convert expression to string and remove trailing space, if any
			var sb = expression.ToStringBuilder(0);
			if (sb.Length > 0 && sb[sb.Length - 1] == ' ')
				sb.Length -= 1;

			return PassiveExpression.Build(sb.ToString().ToCharArray());
		}
예제 #11
0
		public PassiveExpression Put(PassiveExpression expression)
		{
			if (expression == null || expression.IsEmpty)
				return Prout(expression);

			string handle = expression[0].ToString();
			StreamWriter sw = OpenFiles[handle] as StreamWriter;

			if (sw == null)
				return Prout(expression);

			sw.WriteLine("{0}", expression.ToStringBuilder(1));

			PassiveExpression result = PassiveExpression.Build(expression);
			result.Remove(result[0]);
			return result;
		}