Ejemplo n.º 1
0
        /// <summary>
        /// 根据路径得到脚本程序
        /// </summary>
        /// <param name="programPath"></param>
        /// <returns></returns>
        private FluidProgram GetProgram(string programPath)
        {
            if (programPath == null)
            {
                return(null);
            }

            Stream fstream = null;

            try
            {
                FluidProgram program = FluidProgram.GetProgram(fstream, programPath);

                //如果不在空闲时,则返回
                if (Executor.Instance.CurrProgramState != Executor.ProgramOuterState.IDLE &&
                    Executor.Instance.CurrProgramState != Executor.ProgramOuterState.ABORTED)
                {
                    return(null);
                }

                //进行语法检查
                Result rst = program.Parse();
                if (!rst.IsOk)
                {
                    MessageBox.Show("该程序存在语法错误,无法加载!");
                    return(null);
                }
                return(program);
            }
            catch (Exception)
            {
                return(null);
            }
            finally
            {
                if (fstream != null)
                {
                    fstream.Close();
                }
            }
        }