BSky.Statistics.R.RService.EvaluateNoReturn C# (CSharp) Method

EvaluateNoReturn() public method

public EvaluateNoReturn ( string commandString ) : string
commandString string
return string
        public string EvaluateNoReturn(string commandString)
        {
            string errmsg = string.Empty;
            try
            {
                this._log.ClearErrorConsole();
                this._RServer.Evaluate(commandString);
                if (this._log.LastError != null && this._log.LastError.Length > 0)
                    errmsg = this.GetErrorText();//this flushes the old error. Cleaned for next.
            }
            catch (Exception ex)
            {
                if (this._log.LastError != null && this._log.LastError.Length > 0)
                    errmsg = this.GetErrorText();//this flushes the old error. Cleaned for next.
                else
                    errmsg = "Exception occurred but no error message from R.";// _RServer.GetErrorText();// _log.LastError;
                LastException = ex;
                logService.WriteToLogLevel("Could not execute: < " + commandString + " >", LogLevelEnum.Error);
            }
            return errmsg;
        }

Usage Example

        public RPackageManager(RService dispatcher, Journal journal)
        {
            _journal = journal;
            _dispatcher = dispatcher;

            //can be executed once here and then no need to use it methods below.
            string errmsg = _dispatcher.EvaluateNoReturn("library(tools)");
            if (errmsg != null && errmsg.Trim().Length < 1) //error occurred
            {

            }
        }