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

Show error#5604 #5611

Merged
merged 6 commits into from
Feb 3, 2020
Merged

Conversation

Ivanluv
Copy link
Contributor

@Ivanluv Ivanluv commented Dec 5, 2019

fixes #5604
@africanmathsinitiative/developers this is ready for review

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was exciting, so I tried the branch. But I can't see where I should test this? I assume I am too early?

@rdstern
Copy link
Collaborator

rdstern commented Dec 9, 2019

@Ivanluv I have now found it:
image

Perfect. Can we have this whenever there is a Try. It is just what I was hoping for.

@Ivanluv
Copy link
Contributor Author

Ivanluv commented Jan 7, 2020

@Patowhiz could you please review this

@Ivanluv
Copy link
Contributor Author

Ivanluv commented Jan 7, 2020

@rdstern could you please look at this again

@rdstern
Copy link
Collaborator

rdstern commented Jan 7, 2020

What has changed to look at now? I assume that the Try is a user control and hence the display of the error would be a feature on each dialogue with the Try control? So I looked at the Prepare > Column: Caslculate > Calculations and also Column: Generate > Enter and it doesn't seem to be there yet.

Am I wrong? I assume your code adds to the Try User control, so it could automatically be everywhere that there is a Try?

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked where I remembered the halfway dialogues and it seems to work very well. Great. Please can it be merged.
I looked at the Model Hypothesis Tests, Model and Use Model and General Fit Model.
In prepare I looked at the Calculate and at Enter.
The one still to check will be the File > New Data Frame once the new version is merged. I assume it is using the same control and hence will work automatically. Perhaps @Patowhiz can confirm. But this should not hold up the merging of this improvement.

Public Class ucrTry
Public bFirstLoad As Boolean = False
Private bIsCommand As Boolean = False
Private CommandModel As String = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this

Suggested change
Private CommandModel As String = ""
Private strCommandModel As String = ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ivanluv @maxwellfundi was this done before it was merged?

End Try
End Sub

Private Sub AddButtonInTryTextBox()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patowhiz This button code has been replicated here. Suggest we move this into a user control to avoid duplication. Not urgent though. Can you add an issue for it?

@dannyparsons
Copy link
Contributor

@maxwellfundi Can you look at this? We are almost ready to merge it but there's conflicts with the calculator.

@maxwellfundi
Copy link
Contributor

@dannyparsons Am on it now actually.

@maxwellfundi maxwellfundi merged commit 07ec9b8 into IDEMSInternational:master Feb 3, 2020
Ivanluv added a commit to Ivanluv/R-Instat that referenced this pull request Feb 3, 2020
@Patowhiz
Copy link
Contributor

Patowhiz commented Feb 3, 2020

@Ivanluv @dannyparsons @rdstern this is what I did for checking if the commands typed produce a dataframe. Basically, I'm going through all the commands line by line making sure that each command ios correct and checking the output of the last command also. I don't if this could help in ucrTry control.

 Private Sub cmdTry_Click(sender As Object, e As EventArgs) Handles btnTry.Click
        Dim bValid As Boolean = False
        Dim vecOutput As CharacterVector
        Dim strScript As String
        Dim lstScriptCommands As New List(Of String)
        Try


            If rdoConstruct.Checked Then
                Dim clsTempConstructFunction As RFunction
                clsTempConstructFunction = clsConstructFunction.Clone
                clsTempConstructFunction.bToBeAssigned = False
                clsTempConstructFunction.bIsAssigned = False
                strScript = clsTempConstructFunction.ToScript()
                lstScriptCommands.AddRange(strScript.Split(New String() {Environment.NewLine}, StringSplitOptions.None))
            ElseIf rdoCommand.Checked OrElse rdoRandom.Checked Then
                strScript = ucrInputCommand.GetText
                lstScriptCommands.AddRange(strScript.Split(New String() {Environment.NewLine}, StringSplitOptions.None))
            End If

            'always run line by line. The last line should produuce a dataframe
            For Each str As String In lstScriptCommands
                If Not String.IsNullOrWhiteSpace(str) Then
                    vecOutput = frmMain.clsRLink.RunInternalScriptGetOutput(str, bSilent:=True)
                    If vecOutput Is Nothing Then
                        bValid = False
                        Exit For
                    ElseIf vecOutput.Length > 0 Then
                        bValid = True
                        'don't break the if, we probably want to loop through to the last command checking validity? 
                    End If
                End If
            Next


            If ucrBase.cmdOk.Enabled AndAlso bValid Then
                ucrInputTryMessage.SetText("Command Ok.")
                ucrInputTryMessage.txtInput.BackColor = Color.LightGreen
            Else
                ucrInputTryMessage.SetText("Command produced an error or no output to display.")
                ucrInputTryMessage.txtInput.BackColor = Color.LightCoral
            End If


        Catch ex As Exception
            ucrInputTryMessage.SetText("Command produced an error.")
            ucrInputTryMessage.txtInput.BackColor = Color.LightCoral
        End Try
    End Sub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancing the Try control in R-Instat to be able to show errors
5 participants