Skip to content

Commit 84b1ad9

Browse files
authored
Merge pull request #9096 from derekagorhom/Allow_for_Import_Json_File
Added the Option of Loading and Saving Json Files in the R script window
2 parents 8307206 + df6561f commit 84b1ad9

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

instat/ucrScript.vb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,10 @@ Public Class ucrScript
214214

215215
Using dlgSave As New SaveFileDialog
216216
dlgSave.Title = "Save " & If(bIsLog, "Log", "Script") & " To File"
217-
dlgSave.Filter = "R Script File (*.R)|*.R|Text File (*.txt)|*.txt"
217+
dlgSave.Filter = "R Script File (*.R)|*.R|Text File (*.txt)|*.txt|JSON File (*.json)|*.json"
218218
dlgSave.FileName = Path.GetFileName(TabControl.SelectedTab.Text)
219219

220-
'Ensure that dialog opens in correct folder.
221-
'In theory, we should be able to use `dlgLoad.RestoreDirectory = True` but this does
222-
'not work (I think a bug in WinForms).So we need to use static variables instead.
220+
' Ensure that dialog opens in the correct folder.
223221
Static strInitialDirectory As String = frmMain.clsInstatOptions.strWorkingDirectory
224222
Static strInitialDirectoryLog As String = frmMain.clsInstatOptions.strWorkingDirectory
225223
dlgSave.InitialDirectory = If(bIsLog, strInitialDirectoryLog, strInitialDirectory)
@@ -232,15 +230,16 @@ Public Class ucrScript
232230
TabControl.SelectedTab.Text = System.IO.Path.GetFileNameWithoutExtension(dlgSave.FileName)
233231
frmMain.clsRecentItems.addToMenu(Replace(Path.Combine(Path.GetFullPath(strInitialDirectory), System.IO.Path.GetFileName(dlgSave.FileName)), "\", "/"))
234232
frmMain.bDataSaved = True
233+
235234
If bIsLog Then
236235
strInitialDirectoryLog = Path.GetDirectoryName(dlgSave.FileName)
237236
Else
238237
strInitialDirectory = Path.GetDirectoryName(dlgSave.FileName)
239238
End If
240239
Catch
241240
MsgBox("Could not save the " & If(bIsLog, "Log", "Script") & " file." & Environment.NewLine &
242-
"The file may be in use by another program or you may not have access to write to the specified location.",
243-
vbExclamation, "Save " & If(bIsLog, "Log", "Script"))
241+
"The file may be in use by another program or you may not have access to write to the specified location.",
242+
vbExclamation, "Save " & If(bIsLog, "Log", "Script"))
244243
End Try
245244
End If
246245
End Using
@@ -530,9 +529,9 @@ Public Class ucrScript
530529

531530
Using dlgLoad As New OpenFileDialog
532531
dlgLoad.Title = "Load Script From Text File"
533-
dlgLoad.Filter = "Text & R Script Files (*.txt,*.R)|*.txt;*.R|R Script File (*.R)|*.R|Text File (*.txt)|*.txt"
532+
dlgLoad.Filter = "Text & R Script Files (*.txt, *.R, *.json)|*.txt;*.R;*.json|R Script File (*.R)|*.R|Text File (*.txt)|*.txt|JSON File (*.json)|*.json"
534533

535-
'Ensure that dialog opens in correct folder.
534+
' Ensure that dialog opens in the correct folder.
536535
'In theory, we should be able to use `dlgLoad.RestoreDirectory = True` but this does
537536
'not work (I think a bug in WinForms).So we need to use a static variable instead.
538537
Static strInitialDirectory As String = frmMain.clsInstatOptions.strWorkingDirectory

0 commit comments

Comments
 (0)