private void _appendFunction(RPN_Function f)
 {
     if (_functions.Count >= MK52_NFUNCTIONS)
     {
         return;
     }
     _functions.Add(f);
 }
        public void execute(uint id, string command)
        {
            RPN_Function pf = getFunctionByID(id);

            if (pf == null)
            {
                return;
            }
            pf.execute(_parent, command);
        }
Beispiel #3
0
        public void listFunctions(string filename)
        {
            FileStream   fs = null;
            StreamWriter sw = null;

            try
            {
                fs = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
                sw = new StreamWriter(fs);

                sw.Write("#\n");
                sw.Write("# MK-52 implemented functions " + DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss\n"));
                sw.Write("#\n");
                for (int i = 0; i < RPN_Functions.MK52_NFUNCTIONS; i++)
                {
                    sw.Write(i.ToString("000"));
                    sw.Write("\t");
                    RPN_Function f = _m_RPN_Functions.getFunctionByID((uint)i);
                    if (f == null)
                    {
                        sw.Write("slot empty\n");
                        continue;
                    }
                    if (f.IOName() == null || f.IOName().Length == 0)
                    {
                        sw.Write("No name");
                    }
                    else
                    {
                        sw.Write(f.IOName());
                    }
                    sw.Write("\t");
                    sw.Write(f.Description);
                    sw.Write("\n");
                }
            }
            catch
            {
                this._m_RPN_Stack.setLabel_P(0, "Error: file save");
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
 public RPN_Function getFunctionByName(string command)
 {
     for (int i = 0; i < _functions.Count; i++)
     {
         RPN_Function pf = _functions[i];
         if (!pf.checkName(command))
         {
             continue;
         }
         return(pf);
     }
     return(null);
 }
 public void execute(string command)
 {
     for (int i = 0; i < _functions.Count; i++)
     {
         RPN_Function pf = _functions[i];
         if (!pf.checkName(command))
         {
             continue;
         }
         int operand = pf.Name().Length;
         pf.execute(_parent, command.Substring(operand));
         pf.advancePC(_parent);
         return;
     }
     rpnStack.setLabel(0, command);
     progMem.incrementCounter();
 }
 public RPN_Function getFunctionByIOName(string command)
 {
     if (command.Length <= 0)
     {
         return(null);
     }
     for (int i = 0; i < _functions.Count; i++)
     {
         RPN_Function pf = _functions[i];
         if (!UniversalValue._startsWith_P(command, pf.IOName()))
         {
             continue;
         }
         return(pf);
     }
     return(null);
 }
 public RPN_Function getFunctionByID(uint id)
 {
     // TODO
     if (id < 0)
     {
         return(null);
     }
     for (int i = 0; i < _functions.Count; i++)
     {
         RPN_Function pf = _functions[i];
         if (!pf.checkID(id))
         {
             continue;
         }
         return(pf);
     }
     return(null);
 }
        public void renumberAdresses(uint fromLine, int shift)
        {
            uint tmpCounter = _counter;

            resetCounter();
            while (_current < _bottom)
            {
                string       progLine = getCurrentLine();
                RPN_Function fn       = _parent._m_RPN_Functions.getFunctionByName(progLine);
                if (fn != null && fn.containsPC())
                {
                    int    operand = fn.Name().Length;
                    string addrStr = progLine.Substring(operand);
                    addrStr = modifyAddress(addrStr, fromLine, shift);
                    replaceLine(fn.Name() + addrStr);
                }
                incrementCounter();
            }
            setCounter(tmpCounter);
        }