Skip to content

Commit

Permalink
Merge pull request IDEMSInternational#8853 from lloyddewit/8852Effici…
Browse files Browse the repository at this point in the history
…entNewScript

Ensured that R script only analysed if it has changed since the last analysis
  • Loading branch information
N-thony authored Mar 4, 2024
2 parents 3f4aef0 + 3e0d31b commit 7a9c114
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions instat/ucrScript.vb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Public Class ucrScript
Private bIsTextChanged = False
Private iMaxLineNumberCharLength As Integer = 0
Private Const iTabIndexLog As Integer = 0
Private clsRScript As RScript = Nothing
Private strRInstatLogFilesFolderPath As String = Path.Combine(Path.GetFullPath(FileIO.SpecialDirectories.MyDocuments), "R-Instat_Log_files")

Friend WithEvents clsScriptActive As Scintilla
Expand Down Expand Up @@ -298,6 +299,7 @@ Public Class ucrScript

TabControl.SelectedTab = tabPageAdded
bIsTextChanged = False
clsRScript = Nothing
EnableDisableButtons()
End Sub

Expand Down Expand Up @@ -544,6 +546,7 @@ Public Class ucrScript
TabControl.SelectedTab.Text = System.IO.Path.GetFileNameWithoutExtension(dlgLoad.FileName)
strInitialDirectory = Path.GetDirectoryName(dlgLoad.FileName)
bIsTextChanged = False
clsRScript = Nothing
frmMain.clsRecentItems.addToMenu(Replace(Path.Combine(Path.GetFullPath(FileIO.SpecialDirectories.MyDocuments), System.IO.Path.GetFileName(dlgLoad.FileName)), "\", "/"))
frmMain.bDataSaved = True
Catch
Expand Down Expand Up @@ -643,7 +646,10 @@ Public Class ucrScript
Try
Dim dctRStatements As OrderedDictionary
Try
dctRStatements = New RScript(clsScriptActive.Text).statements
If clsRScript Is Nothing Then
clsRScript = New RScript(clsScriptActive.Text)
End If
dctRStatements = clsRScript.statements
Catch ex As Exception
MsgBox("R script parsing failed with message:" & Environment.NewLine _
& Environment.NewLine & ex.Message & Environment.NewLine & Environment.NewLine _
Expand Down Expand Up @@ -763,6 +769,7 @@ Public Class ucrScript

Private Sub clsScriptActive_TextChanged(sender As Object, e As EventArgs) Handles clsScriptActive.TextChanged
bIsTextChanged = True
clsRScript = Nothing
EnableDisableButtons()
SetLineNumberMarginWidth(clsScriptActive.Lines.Count.ToString().Length)
End Sub
Expand Down Expand Up @@ -980,7 +987,7 @@ Public Class ucrScript
'This is just to be on the safe side. It is not worth the extra complexity of
'checking if the script is the same as the associated file name
bIsTextChanged = clsScriptActive.TextLength > 0

clsRScript = Nothing
EnableDisableButtons()
Exit Sub
End If
Expand Down

0 comments on commit 7a9c114

Please sign in to comment.