Skip to content

Commit

Permalink
Merge pull request #214 from IDEMSInternational/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
MeSophie authored Apr 16, 2024
2 parents 329d2c7 + ce9d7de commit e8f52d5
Show file tree
Hide file tree
Showing 74 changed files with 4,597 additions and 2,066 deletions.
16 changes: 16 additions & 0 deletions instat/DlgUseDate.vb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

Imports instat.Translations
Public Class dlgUseDate
Public enumUsedateMode As String = UsedateMode.Prepare
Public Enum UsedateMode
Prepare
Climatic
End Enum

Private bReset As Boolean = True
Public bFirstLoad As Boolean = True
Public strDefaultDataFrame As String = ""
Expand All @@ -32,6 +38,7 @@ Public Class dlgUseDate
End If
SetRCodeforControls(bReset)
SetDefaultColumn()
SetHelpOptions()
bReset = False
autoTranslate(Me)
End Sub
Expand Down Expand Up @@ -226,6 +233,15 @@ Public Class dlgUseDate
End If
End Sub

Private Sub SetHelpOptions()
Select Case enumUsedateMode
Case UsedateMode.Prepare
ucrBase.iHelpTopicID = 462
Case UsedateMode.Climatic
ucrBase.iHelpTopicID = 494
End Select
End Sub

Private Sub ucrControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverUseDate.ControlContentsChanged, ucrChkWeekName.ControlContentsChanged, ucrChkWeekdayNum.ControlContentsChanged, ucrChkWeekNum.ControlContentsChanged, ucrChkShiftPentadNum.ControlContentsChanged, ucrChkShiftPentadAbbr.ControlContentsChanged, ucrChkShiftDekadAbbr.ControlContentsChanged, ucrChkWeekAbbr.ControlContentsChanged, ucrChkShiftMonthNum.ControlContentsChanged, ucrChkLeapYearNum.ControlContentsChanged, ucrChkWeekdayName.ControlContentsChanged, ucrChkShiftMonthName.ControlContentsChanged, ucrChkShiftDekadNum.ControlContentsChanged, ucrChkDayInMonthNum.ControlContentsChanged, ucrChkDayInYearNum.ControlContentsChanged, ucrChkWeekdayAbbr.ControlContentsChanged, ucrChkShiftMonthAbbr.ControlContentsChanged, ucrChkShiftDayInYearNum366.ControlContentsChanged, ucrChkShiftYearNum.ControlContentsChanged, ucrChkShiftYearName.ControlContentsChanged, ucrChkShiftDayInYearNum366.ControlContentsChanged, ucrChkShiftQuarterNum.ControlContentsChanged, ucrInputComboBoxStartingMonth.ControlContentsChanged, ucrChkDaysInMonthNum.ControlContentsChanged, ucrChkShiftQuarterAbbr.ControlContentsChanged
TestOKEnabled()
End Sub
Expand Down
167 changes: 51 additions & 116 deletions instat/clsRCodeStructure.vb

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions instat/clsRFunction.vb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ Public Class RFunction
''' <summary> The R command's package name. </summary>
Private strPackageName As String = ""

''' <summary> Initializes a new instance of this class. </summary>
Public Sub New()
OnParametersChanged() 'TODO SJL is this still needed?
End Sub

'''--------------------------------------------------------------------------------------------
''' <summary> Sets the R command's name (e.g. "facet_grid") and flags that the R script
''' associated with this object is no longer correctly assigned.</summary>
Expand Down Expand Up @@ -228,7 +223,6 @@ Public Class RFunction
clsRFunction.iPosition = iPosition
clsRFunction.iCallType = iCallType
clsRFunction.bExcludeAssignedFunctionOutput = bExcludeAssignedFunctionOutput
clsRFunction.bClearFromGlobal = bClearFromGlobal
clsRFunction.bToScriptAsRString = bToScriptAsRString
clsRFunction.Tag = Tag
For Each clsRParam In clsParameters
Expand Down
57 changes: 45 additions & 12 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,24 @@ Public Class RLink
bShowWaitDialogOverride:=Nothing)
End If

clsOutputLogger.AddOutput(clsRStatement.Text, strOutput, bAsFile:=True,
bDisplayOutputInExternalViewer:=clsRStatement.TextNoFormatting.StartsWith("view_object_data"))
' Split the strOutput into an array of lines, removing empty entries
Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)

' Check if arrFilesPaths has at least one element before iterating
If arrFilesPaths.Length > 0 Then
' Iterate through each file path
For Each _path In arrFilesPaths
' Add output to logger
clsOutputLogger.AddOutput(clsRStatement.Text, _path, bAsFile:=True,
bDisplayOutputInExternalViewer:=clsRStatement.TextNoFormatting.StartsWith("view_object_data"))
Next
Else
' Add output to logger
clsOutputLogger.AddOutput(clsRStatement.Text, strOutput, bAsFile:=True,
bDisplayOutputInExternalViewer:=clsRStatement.TextNoFormatting.StartsWith("view_object_data"))
End If

' Log the script
LogScript(clsRStatement.Text.TrimEnd(vbCr, vbLf))

Catch e As Exception
Expand Down Expand Up @@ -996,9 +1012,23 @@ Public Class RLink
End If
End If

If bAsFile Then
' Split the strOutput into an array of lines, removing empty entries
Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
' Iterate through each HTML files
For Each _path In arrFilesPaths
' Add each HTML file as an output to clsOutputLogger
' strScriptWithComment: the script with associated comments
' _path: the path to the HTML file
' bAsFile: a boolean indicating whether the output should be treated as a file
' bDisplayOutputInExternalViewer: a boolean indicating whether to display the output in an external viewer
clsOutputLogger.AddOutput(strScriptWithComment, _path, bAsFile, bDisplayOutputInExternalViewer)
Next
Else
' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output
clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer)
End If

'log script and output
clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer)

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)")
Expand All @@ -1020,7 +1050,7 @@ Public Class RLink
''' <param name="bShowWaitDialogOverride"></param>
''' <returns>file path name if file is avaialble and has contents else empty string</returns>
Private Function GetFileOutput(strScript As String, bSilent As Boolean, bSeparateThread As Boolean, bShowWaitDialogOverride As Nullable(Of Boolean)) As String
Dim strFilePath As String = ""
Dim strFilesPath As String = ""
Dim strTempAssignTo As String = ".temp_val"
Dim expTemp As RDotNet.SymbolicExpression
Dim strNewAssignedToScript As String = ConstructAssignTo(strTempAssignTo, strScript)
Expand All @@ -1029,14 +1059,17 @@ Public Class RLink
expTemp = GetSymbol(strTempAssignTo, bSilent:=True)
Evaluate("rm(" & strTempAssignTo & ")", bSilent:=True)
If expTemp IsNot Nothing Then
'get the file path name, check if it exists and whether it has contents
'if not, just return empty file path
strFilePath = String.Join(Environment.NewLine, expTemp.AsCharacter())
If Not File.Exists(strFilePath) OrElse New FileInfo(strFilePath).Length = 0 Then
strFilePath = ""
End If
' Convert CharacterVector to String() array
Dim arrFilesPath As String() = expTemp.AsCharacter().Select(Function(x) x.ToString()).ToArray()

' Filter out invalid file paths
arrFilesPath = arrFilesPath.Where(Function(path) File.Exists(path) AndAlso New FileInfo(path).Length > 0).ToArray()

' Join the valid file paths with newline characters
strFilesPath = String.Join(Environment.NewLine, arrFilesPath)
End If
Return strFilePath

Return strFilesPath
End Function

'''--------------------------------------------------------------------------------------------
Expand Down
18 changes: 0 additions & 18 deletions instat/clsROperator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ Public Class ROperator
Public Sub SetOperation(strTemp As String, Optional bBracketsTemp As Boolean = True)
strOperation = strTemp
bBrackets = bBracketsTemp
'bIsAssigned = False
End Sub

'''--------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -264,22 +263,6 @@ Public Class ROperator
Return Nothing
End Function

''' <summary> Removes all additional parameters. </summary>
Public Sub RemoveAllAdditionalParameters()
'TODO SJL 03/04/20 this function is only used by 1 dialog. This hints that there may be an alternative way of doing the same thing.
' It's also suspicious that the other RCodeStructure classes don't have such a function. Why is it only needed for an operator?
' Can this function be removed?
SortParameters() 'This is used to bring the parameter with position 0 to the front if it exists, then clear all the others using range.
If clsParameters(0).Position = 0 Then
If clsParameters.Count > 1 Then
clsParameters.RemoveRange(1, clsParameters.Count - 1)
End If
Else
clsParameters.Clear()
End If
OnParametersChanged()
End Sub

''' <summary> Clears this object to its blank/initial state. </summary>
Public Overrides Sub Clear()
SetOperation("")
Expand Down Expand Up @@ -310,7 +293,6 @@ Public Class ROperator
clsTempROperator.iPosition = iPosition
clsTempROperator.iCallType = iCallType
clsTempROperator.bExcludeAssignedFunctionOutput = bExcludeAssignedFunctionOutput
clsTempROperator.bClearFromGlobal = bClearFromGlobal
clsTempROperator.bToScriptAsRString = bToScriptAsRString
clsTempROperator.Tag = Tag
For Each clsRParam In clsParameters
Expand Down
Loading

0 comments on commit e8f52d5

Please sign in to comment.