From 2cdb1a3dfa9ecd3a1dd90b66716f9911b13cf392 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 11 Apr 2024 13:33:34 +0300 Subject: [PATCH 1/6] Completing the multiple tables(html) in output window --- instat/Model/Output/clsOutputLogger.vb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index 25e04fc2083..05724869eab 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -77,13 +77,22 @@ Public Class clsOutputLogger Exit Sub End If - 'add the R script as an output element - Dim rScriptElement As New clsOutputElement - rScriptElement.SetContent(strScript, OutputType.Script, "") - _outputElements.Add(rScriptElement) - 'raise event for output pages - RaiseEvent NewOutputAdded(rScriptElement, False) + ' Used to hold the previous script value + Static strCurrentScript As String = "" + ' Check if the new script is different from the previous one + If strScript <> strCurrentScript Then + 'add the R script as an output element + Dim rScriptElement As New clsOutputElement + rScriptElement.SetContent(strScript, OutputType.Script, "") + _outputElements.Add(rScriptElement) + + ' Update the previous script constant + strCurrentScript = strScript + + 'raise event for output pages + RaiseEvent NewOutputAdded(rScriptElement, False) + End If If Not String.IsNullOrEmpty(strOutput) Then Dim outputElement As New clsOutputElement From e75b61b46eadd2ff31d25a45c8a0d3c295ca42dd Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 11 Apr 2024 13:46:13 +0300 Subject: [PATCH 2/6] removed space --- instat/Model/Output/clsOutputLogger.vb | 3 --- 1 file changed, 3 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index 05724869eab..7a0f9282aec 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -124,9 +124,6 @@ Public Class clsOutputLogger RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer) End If - - - End Sub ''' From 290a4420c0e6d1d99f3f6d57406b499231acc044 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 11 Apr 2024 13:50:12 +0300 Subject: [PATCH 3/6] renaming the variables --- instat/Model/Output/clsOutputLogger.vb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index 7a0f9282aec..672c8a76d94 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -70,25 +70,25 @@ Public Class clsOutputLogger End Set End Property - Public Sub AddOutput(strScript As String, strOutput As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) + Public Sub AddOutput(strNewScript As String, strOutput As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) 'Note this always takes the last script added as corresponding script - If String.IsNullOrWhiteSpace(strScript) Then + If String.IsNullOrWhiteSpace(strNewScript) Then Throw New Exception("Cannot find script to attach output to.") Exit Sub End If - ' Used to hold the previous script value + ' Used to hold the current script value Static strCurrentScript As String = "" - ' Check if the new script is different from the previous one - If strScript <> strCurrentScript Then + ' Check if the new script is different from the current one + If strNewScript <> strCurrentScript Then 'add the R script as an output element Dim rScriptElement As New clsOutputElement - rScriptElement.SetContent(strScript, OutputType.Script, "") + rScriptElement.SetContent(strNewScript, OutputType.Script, "") _outputElements.Add(rScriptElement) - ' Update the previous script constant - strCurrentScript = strScript + ' Update the current script + strCurrentScript = strNewScript 'raise event for output pages RaiseEvent NewOutputAdded(rScriptElement, False) From 58a18e34d1cb173ba344c89cd9b715283686aa71 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Mon, 22 Apr 2024 20:30:02 +0300 Subject: [PATCH 4/6] refactored AddOutput --- instat/Model/Output/clsOutputLogger.vb | 87 +++++++++++--------------- instat/clsRLink.vb | 41 ++++-------- 2 files changed, 49 insertions(+), 79 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index 672c8a76d94..a5dbd697490 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -70,60 +70,49 @@ Public Class clsOutputLogger End Set End Property - Public Sub AddOutput(strNewScript As String, strOutput As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) - 'Note this always takes the last script added as corresponding script - If String.IsNullOrWhiteSpace(strNewScript) Then + Public Sub AddOutput(strScript As String, strOutput() As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) + ' Note this always takes the last script added as corresponding script + If String.IsNullOrWhiteSpace(strScript) Then Throw New Exception("Cannot find script to attach output to.") Exit Sub End If - ' Used to hold the current script value - Static strCurrentScript As String = "" - - ' Check if the new script is different from the current one - If strNewScript <> strCurrentScript Then - 'add the R script as an output element - Dim rScriptElement As New clsOutputElement - rScriptElement.SetContent(strNewScript, OutputType.Script, "") - _outputElements.Add(rScriptElement) - - ' Update the current script - strCurrentScript = strNewScript - - 'raise event for output pages - RaiseEvent NewOutputAdded(rScriptElement, False) - End If - - If Not String.IsNullOrEmpty(strOutput) Then - Dim outputElement As New clsOutputElement - Dim outputType As OutputType - If bAsFile Then - Dim strFileExtension As String = Path.GetExtension(strOutput).ToLower - Select Case strFileExtension - Case ".png" - outputType = OutputType.ImageOutput - Case ".html" - outputType = OutputType.HtmlOutput - Case ".txt" - outputType = OutputType.TextOutput - Case Else - MessageBox.Show("The file type to be added is currently not suported", - "Developer Error", - MessageBoxButtons.OK, - MessageBoxIcon.Error) - Exit Sub - End Select - Else - outputType = OutputType.TextOutput + ' Add the R script as an output element + Dim rScriptElement As New clsOutputElement + rScriptElement.SetContent(strScript, OutputType.Script, "") + _outputElements.Add(rScriptElement) + ' Raise event for output pages + RaiseEvent NewOutputAdded(rScriptElement, False) + + For Each output In strOutput + If Not String.IsNullOrEmpty(output) Then + Dim outputElement As New clsOutputElement + Dim outputType As OutputType + + If bAsFile Then + Dim strFileExtension As String = Path.GetExtension(output).ToLower + Select Case strFileExtension + Case ".png" + outputType = OutputType.ImageOutput + Case ".html" + outputType = OutputType.HtmlOutput + Case ".txt" + outputType = OutputType.TextOutput + Case Else + MessageBox.Show("The file type to be added is currently not supported", "Developer Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + Exit Sub + End Select + Else + outputType = OutputType.TextOutput + End If + + ' Add the output with its R script as another output element + outputElement.SetContent("", outputType, output) + _outputElements.Add(outputElement) + ' Raise event for output pages + RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer) End If - - 'add the output with it's R script as another output element - outputElement.SetContent("", outputType, strOutput) - '_outputElements.Add(outputElement) - 'raise event for output pages - RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer) - - End If + Next End Sub ''' diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index b5bae7a3a64..302d7fabe78 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -749,22 +749,12 @@ Public Class RLink bShowWaitDialogOverride:=Nothing) End If - ' Split the strOutput into an array of lines, removing empty entries + ' 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, + ' Add output to logger + clsOutputLogger.AddOutput(clsRStatement.Text, arrFilesPaths, 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)) @@ -868,9 +858,11 @@ Public Class RLink Evaluate(strRStatement, bSilent:=False, bSeparateThread:=False, bShowWaitDialogOverride:=Nothing) End If + ' Split the strOutput into an array of lines, removing empty entries + Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) clsOutputLogger.AddOutput(If(String.IsNullOrEmpty(strRStatementComment), "", strRStatementComment & Environment.NewLine) & strRStatement, - strOutput, bAsFile, bDisplayOutputInExternalViewer) + arrFilesPaths, bAsFile, bDisplayOutputInExternalViewer) LogScript(strRStatement, strRStatementComment) Catch e As Exception @@ -1012,22 +1004,11 @@ 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 + ' Split the strOutput into an array of lines, removing empty entries + Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) + + ' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output + clsOutputLogger.AddOutput(strScriptWithComment, arrFilesPaths, bAsFile, bDisplayOutputInExternalViewer) Catch e As Exception From e0ed114afa806c979c17619549e0dec3ff16892e Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Mon, 22 Apr 2024 20:48:24 +0300 Subject: [PATCH 5/6] minor code change --- instat/Model/Output/clsOutputLogger.vb | 7 +++++-- instat/clsRLink.vb | 14 +++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index a5dbd697490..8d9c6479e0b 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -70,7 +70,7 @@ Public Class clsOutputLogger End Set End Property - Public Sub AddOutput(strScript As String, strOutput() As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) + Public Sub AddOutput(strScript As String, strOutput As String, bAsFile As Boolean, bDisplayOutputInExternalViewer As Boolean) ' Note this always takes the last script added as corresponding script If String.IsNullOrWhiteSpace(strScript) Then Throw New Exception("Cannot find script to attach output to.") @@ -84,7 +84,10 @@ Public Class clsOutputLogger ' Raise event for output pages RaiseEvent NewOutputAdded(rScriptElement, False) - For Each output In strOutput + ' Split the strOutput into an array of lines, removing empty entries + Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) + + For Each output In arrFilesPaths If Not String.IsNullOrEmpty(output) Then Dim outputElement As New clsOutputElement Dim outputType As OutputType diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 302d7fabe78..10c9557861a 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -749,11 +749,8 @@ Public Class RLink bShowWaitDialogOverride:=Nothing) End If - ' Split the strOutput into an array of lines, removing empty entries - Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) - ' Add output to logger - clsOutputLogger.AddOutput(clsRStatement.Text, arrFilesPaths, bAsFile:=True, + clsOutputLogger.AddOutput(clsRStatement.Text, strOutput, bAsFile:=True, bDisplayOutputInExternalViewer:=clsRStatement.TextNoFormatting.StartsWith("view_object_data")) ' Log the script @@ -858,11 +855,9 @@ Public Class RLink Evaluate(strRStatement, bSilent:=False, bSeparateThread:=False, bShowWaitDialogOverride:=Nothing) End If - ' Split the strOutput into an array of lines, removing empty entries - Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) clsOutputLogger.AddOutput(If(String.IsNullOrEmpty(strRStatementComment), "", strRStatementComment & Environment.NewLine) & strRStatement, - arrFilesPaths, bAsFile, bDisplayOutputInExternalViewer) + strOutput, bAsFile, bDisplayOutputInExternalViewer) LogScript(strRStatement, strRStatementComment) Catch e As Exception @@ -1004,11 +999,8 @@ Public Class RLink End If End If - ' Split the strOutput into an array of lines, removing empty entries - Dim arrFilesPaths() As String = strOutput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) - ' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output - clsOutputLogger.AddOutput(strScriptWithComment, arrFilesPaths, bAsFile, bDisplayOutputInExternalViewer) + clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer) Catch e As Exception From d6146ad030d5c91b332564c5e4fce5cbaf2075d9 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Tue, 21 May 2024 17:55:34 +0300 Subject: [PATCH 6/6] resolved the build error --- instat/Model/Output/clsOutputLogger.vb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/instat/Model/Output/clsOutputLogger.vb b/instat/Model/Output/clsOutputLogger.vb index 809761f4d43..1c6b5d4396d 100644 --- a/instat/Model/Output/clsOutputLogger.vb +++ b/instat/Model/Output/clsOutputLogger.vb @@ -117,15 +117,6 @@ Public Class clsOutputLogger End If Next - 'add the output with it's R script as another output element - outputElement.SetContent("", outputType, strOutput) - _outputElements.Add(outputElement) - 'raise event for output pages - RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer) - - End If - - End Sub '''