Skip to content

Commit

Permalink
Merge pull request #174 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
merge from main
  • Loading branch information
dannyparsons committed May 18, 2016
2 parents 3096587 + 7005a66 commit 1a4847e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
60 changes: 35 additions & 25 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ Public Class RLink
Dim strScriptWithComment As String
Dim strSplitScript As String
strOutput = ""
Try
If strComment <> "" Then
strComment = "# " & strComment
strScriptWithComment = strComment & vbCrLf & strScript
Else
strScriptWithComment = strScript
If strComment <> "" Then
strComment = "# " & strComment
strScriptWithComment = strComment & vbCrLf & strScript
Else
strScriptWithComment = strScript
End If
If bLog Then
txtLog.Text = txtLog.Text & strScriptWithComment & vbCrLf
Expand All @@ -165,35 +164,46 @@ Public Class RLink
End If
AppendText(txtOutput, clrScript, fScript, strScript & vbCrLf)
End If
If bReturnOutput = 0 Then
If bReturnOutput = 0 Then
Try
clsEngine.Evaluate(strScript)
ElseIf bReturnOutput = 1 Then
Catch e As Exception
MsgBox("Error occured in attempting to run:" & vbNewLine & strScript & vbNewLine & vbNewLine & "With error message:" & vbNewLine & e.Message & vbNewLine & vbNewLine, MsgBoxStyle.Critical, "Error running R code")
End Try
ElseIf bReturnOutput = 1 Then
Try
temp = clsEngine.Evaluate(strScript)
strTemp = String.Join(vbCrLf, temp.AsCharacter())
strOutput = strOutput & strTemp & vbCrLf
Catch e As Exception
MsgBox("Error occured in attempting to run:" & vbNewLine & strScript & vbNewLine & vbNewLine & "With error message:" & vbNewLine & e.Message & vbNewLine & vbNewLine, MsgBoxStyle.Critical, "Error running R code")
End Try
Else
If strScript.Trim(vbCrLf).LastIndexOf(vbCrLf) = -1 Then
strCapturedScript = "capture.output(" & strScript & ")"
Else
If strScript.Trim(vbCrLf).LastIndexOf(vbCrLf) = -1 Then
strCapturedScript = "capture.output(" & strScript & ")"
Else
strSplitScript = Left(strScript, strScript.Trim(vbCrLf).LastIndexOf(vbCrLf))
If strSplitScript <> "" Then
strSplitScript = Left(strScript, strScript.Trim(vbCrLf).LastIndexOf(vbCrLf))
If strSplitScript <> "" Then
Try
clsEngine.Evaluate(strSplitScript)
End If
strSplitScript = Right(strScript, strScript.Length - strScript.Trim(vbCrLf).LastIndexOf(vbCrLf) - 2)
strCapturedScript = "capture.output(" & strSplitScript & ")"
Catch e As Exception
MsgBox("Error occured in attempting to run:" & vbNewLine & strSplitScript & vbNewLine & vbNewLine & "With error message:" & vbNewLine & e.Message & vbNewLine & vbNewLine, MsgBoxStyle.Critical, "Error running R code")
End Try
End If
strSplitScript = Right(strScript, strScript.Length - strScript.Trim(vbCrLf).LastIndexOf(vbCrLf) - 2)
strCapturedScript = "capture.output(" & strSplitScript & ")"
End If
Try
temp = clsEngine.Evaluate(strCapturedScript)
strTemp = String.Join(vbCrLf, temp.AsCharacter())
strOutput = strOutput & strTemp & vbCrLf
End If
If bOutput Then
'txtOutput.Text = txtOutput.Text & strOutput
'output format here
AppendText(txtOutput, clrOutput, fOutput, strOutput)
End If
Catch
MsgBox(strScript)
End Try
Catch e As Exception
MsgBox("Error occured in attempting to run:" & vbNewLine & strCapturedScript & vbNewLine & vbNewLine & "With error message:" & vbNewLine & e.Message & vbNewLine & vbNewLine, MsgBoxStyle.Critical, "Error running R code")
End Try
End If
If bOutput Then
AppendText(txtOutput, clrOutput, fOutput, strOutput)
End If
frmMain.clsGrids.UpdateGrids()
End Sub

Expand Down
5 changes: 4 additions & 1 deletion instat/dlgLabels.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Public Class dlgLabels
End Sub

Private Sub TestOKEnabled()
If ucrReceiverLabels.IsEmpty() = False Then
If Not ucrReceiverLabels.IsEmpty() AndAlso ucrFactorLabels.IsColumnComplete(0) Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
Expand Down Expand Up @@ -60,6 +60,7 @@ Public Class dlgLabels

Private Sub ucrFactorLabels_GridContentChanged() Handles ucrFactorLabels.GridContentChanged
ucrBase.clsRsyntax.AddParameter("new_levels", ucrFactorLabels.GetColumnInFactorSheet(iColumn:=0))
TestOKEnabled()
End Sub

Private Sub ucrReceiverLabels_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverLabels.SelectionChanged
Expand All @@ -78,9 +79,11 @@ Public Class dlgLabels

Private Sub cmdAddLevel_Click(sender As Object, e As EventArgs) Handles cmdAddLevel.Click
ucrFactorLabels.AddLevel()
TestOKEnabled()
End Sub

Private Sub ucrFactorLabels_GridVisibleChanged() Handles ucrFactorLabels.GridVisibleChanged
cmdAddLevel.Enabled = ucrFactorLabels.grdFactorData.Visible
TestOKEnabled()
End Sub
End Class
6 changes: 5 additions & 1 deletion instat/dlgView.vb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ Public Class dlgView
End Sub

Private Sub SetDefaults()
nudNumberRows.Value = 6
If nudNumberRows.Maximum >= 6 Then
nudNumberRows.Value = 6
Else
nudNumberRows.Value = nudNumberRows.Maximum
End If
ucrSelctorForView.Reset()
ucrSelctorForView.Focus()
rdoTop.Checked = True
Expand Down
22 changes: 21 additions & 1 deletion instat/ucrFactor.vb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Public Class ucrFactor
End If
Next
End If
ApplyColumnSettings()
End Sub

Public Function GetSelectedLevels() As String
Expand Down Expand Up @@ -262,7 +263,7 @@ Public Class ucrFactor
If i > 0 Then
strTemp = strTemp & ","
End If
If shtCurrSheet(i, iColumn).ToString <> "" Then
If shtCurrSheet(i, iColumn) IsNot Nothing Then
If bWithQuotes Then
strTemp = strTemp & Chr(34) & shtCurrSheet(i, iColumn).ToString & Chr(34)
Else
Expand Down Expand Up @@ -306,4 +307,23 @@ Public Class ucrFactor
Private Sub grdFactorData_VisibleChanged(sender As Object, e As EventArgs) Handles grdFactorData.VisibleChanged
RaiseEvent GridVisibleChanged()
End Sub

Private Sub grdFactorData_Leave(sender As Object, e As EventArgs) Handles grdFactorData.Leave
If shtCurrSheet.IsEditing Then
shtCurrSheet.EndEdit(unvell.ReoGrid.EndEditReason.NormalFinish)
End If
End Sub

Public Function IsColumnComplete(iColumn As Integer) As Boolean
If shtCurrSheet IsNot Nothing AndAlso iColumn < shtCurrSheet.ColumnCount Then
For i = 0 To shtCurrSheet.RowCount - 1
If shtCurrSheet(i, iColumn) Is Nothing OrElse shtCurrSheet(i, iColumn).ToString() = "" Then
Return False
End If
Next
Return True
Else
Return False
End If
End Function
End Class

0 comments on commit 1a4847e

Please sign in to comment.