@@ -223,9 +223,15 @@ Public Class frmMain
223
223
'---------------------------------------
224
224
225
225
'--------------------------------------
226
- CreateAdditionalLibraryDirectory()
226
+ Dim strVersion As String = My.Application.Info.Version.Major.ToString() & "." &
227
+ My.Application.Info.Version.Minor.ToString() & "." &
228
+ My.Application.Info.Version.Build.ToString()
229
+
230
+ Me .Text = "R-Instat " & strVersion
231
+
232
+ CreateAdditionalLibraryDirectory(strVersion)
227
233
'-------------------------------------
228
- SetAppVersionNumber()
234
+
229
235
isMaximised = True 'Need to get the windowstate when the application is loaded
230
236
SetHideMenus()
231
237
End Sub
@@ -411,28 +417,25 @@ Public Class frmMain
411
417
End If
412
418
End Function
413
419
414
- Private Sub CreateAdditionalLibraryDirectory()
420
+ Private Sub CreateAdditionalLibraryDirectory(strVersion As String )
415
421
' Define the custom library path in the ApplicationData folder
416
- Dim strLibraryPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "R-Instat" , "library" )
422
+ Dim strLibraryPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "R-Instat" , strVersion, "library" )
417
423
418
424
Try
419
425
' Check if the directory exists, if not, create it
420
426
If Not Directory.Exists(strLibraryPath) Then
421
427
Directory.CreateDirectory(strLibraryPath)
422
428
End If
423
429
430
+
424
431
'To ensure this part of the code only runs when the application Is Not in the Debug mode (i.e., in Release mode)
425
432
# If Not DEBUG Then
426
- ' Add the custom library path to R's .libPaths for user-level package installation
427
- Dim strScript As String = $".libPaths(c('{strLibraryPath.Replace(" \ ", " / ")}', .libPaths()))" & Environment.NewLine &
428
- "if (length(.libPaths()) > 2 ) {
429
- current_paths <- .libPaths()
430
- valid_indices <- c( 1 , 3 ) [c( 1 , 3 ) <= length(current_paths) ]
431
- .libPaths(current_paths[valid_indices])
432
- } "
433
+ Dim clsSetLibPathsFunction As New RFunction
434
+ clsSetLibPathsFunction.SetRCommand( "set_library_paths" )
435
+ clsSetLibPathsFunction.AddParameter( "library_path" , Chr( 34 ) & strLibraryPath.Replace( "\" , "/" ) & Chr( 34 ))
433
436
434
437
' Execute the R script to update the library paths
435
- clsRLink.RunScript(strScript:=strScript , bSeparateThread:= False , bSilent:= False )
438
+ clsRLink.RunScript(strScript:=clsSetLibPathsFunction.ToScript , bSeparateThread:= False , bSilent:= False )
436
439
# End If
437
440
Catch ex As Exception
438
441
' Handle potential errors (e.g., directory creation failure)
@@ -603,10 +606,8 @@ Public Class frmMain
603
606
mnuTbLan.Visible = bVisible
604
607
End Sub
605
608
606
- Public Sub SetAppVersionNumber()
607
- Me .Text = "R-Instat " & My.Application.Info.Version.Major.ToString() & "." &
608
- My.Application.Info.Version.Minor.ToString() & "." &
609
- My.Application.Info.Version.Build.ToString()
609
+ Public Sub SetAppVersionNumber(strVersionNumber As String )
610
+
610
611
End Sub
611
612
612
613
Private Sub SetHideMenus()
0 commit comments