Beispiel #1
0
        public void FormatString(ProgramReader reader)
        {
            Pointer ptr = new Pointer(Processor.MMU)
            {
                Value = reader.NextPtr()
            };

            string str = ptr.GetString();

            Regex           r       = new Regex(@"\{%[d,s,f]}");
            MatchCollection matches = r.Matches(str);

            foreach (Match match in matches)
            {
                object obj = null;

                if (match.Value == "{%d}")
                {
                    obj = reader.NextInt();
                }
                if (match.Value == "{%f}")
                {
                    obj = reader.NextFloat();
                }
                if (match.Value == "{%s}")
                {
                    obj = new Pointer(Processor.MMU)
                    {
                        Value = reader.NextPtr()
                    }.GetString();
                }

                str = ReplaceFirst(str, match.Value, obj.ToString());
            }

            RangeContainer c = Processor.MMU.Alloc(str.Length + 1);

            c.Write(str);
            Processor.Registers.SetReturnCarry(c.Start);
        }