@@ -223,9 +223,15 @@ Public Class frmMain
223223 '---------------------------------------
224224
225225 '--------------------------------------
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)
227233 '-------------------------------------
228- SetAppVersionNumber()
234+
229235 isMaximised = True 'Need to get the windowstate when the application is loaded
230236 SetHideMenus()
231237 End Sub
@@ -411,28 +417,25 @@ Public Class frmMain
411417 End If
412418 End Function
413419
414- Private Sub CreateAdditionalLibraryDirectory()
420+ Private Sub CreateAdditionalLibraryDirectory(strVersion As String )
415421 ' 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" )
417423
418424 Try
419425 ' Check if the directory exists, if not, create it
420426 If Not Directory.Exists(strLibraryPath) Then
421427 Directory.CreateDirectory(strLibraryPath)
422428 End If
423429
430+
424431 'To ensure this part of the code only runs when the application Is Not in the Debug mode (i.e., in Release mode)
425432# 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 ))
433436
434437 ' 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 )
436439# End If
437440 Catch ex As Exception
438441 ' Handle potential errors (e.g., directory creation failure)
@@ -603,10 +606,8 @@ Public Class frmMain
603606 mnuTbLan.Visible = bVisible
604607 End Sub
605608
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+
610611 End Sub
611612
612613 Private Sub SetHideMenus()
0 commit comments