Skip to content

Commit

Permalink
Merge pull request #398 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
shadrackkibet authored Jan 29, 2020
2 parents 14ec37d + f3788ca commit 8f5ad67
Showing 1 changed file with 12 additions and 7 deletions.
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

0 comments on commit 8f5ad67

Please sign in to comment.