Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #5577 Errors in R-Instat repeat the previous command #5641

Merged
merged 6 commits into from
Jan 29, 2020
19 changes: 12 additions & 7 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ Public Class RLink
Dim clsPNGFunction As New RFunction
Dim strTempAssignTo As String = ".temp_val"
Dim bSuccess As Boolean
Dim bError As Boolean = False

strTempGraphsDirectory = System.IO.Path.Combine(System.IO.Path.GetTempPath() & "R_Instat_Temp_Graphs")
strOutput = ""
Expand Down Expand Up @@ -558,7 +559,7 @@ Public Class RLink
strSplitScript = Left(strScript, strScript.Trim(Environment.NewLine.ToCharArray).LastIndexOf(Environment.NewLine.ToCharArray))
If strSplitScript <> "" Then
Try
Evaluate(strSplitScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride)
bError = Not Evaluate(strSplitScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride)
Catch e As Exception
MsgBox(e.Message & Environment.NewLine & "The error occurred in attempting to run the following R command(s):" & Environment.NewLine & strScript, MsgBoxStyle.Critical, "Error running R command(s)")
End Try
Expand All @@ -567,12 +568,16 @@ Public Class RLink
strCapturedScript = "capture.output(" & strSplitScript & ")"
End If
Try
Evaluate(strTempAssignTo & " <- " & strCapturedScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride)
expTemp = GetSymbol(strTempAssignTo)
If expTemp IsNot Nothing Then
strTemp = String.Join(Environment.NewLine, expTemp.AsCharacter())
If strTemp <> "" Then
strOutput = strOutput & strTemp & Environment.NewLine
If Not bError Then
If Evaluate(strTempAssignTo & " <- " & strCapturedScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride) Then
expTemp = GetSymbol(strTempAssignTo)
Evaluate("rm(" & strTempAssignTo & ")", bSilent:=True)
If expTemp IsNot Nothing Then
strTemp = String.Join(Environment.NewLine, expTemp.AsCharacter())
If strTemp <> "" Then
strOutput = strOutput & strTemp & Environment.NewLine
End If
End If
End If
End If
Catch e As Exception
Expand Down