1- function ProjectShutdown
2- % Reset module to original state that is expected when loading in a new
3- % MATLAB version.
4- proj = currentProject ;
5-
6- MoveFilesAround(" R2023b" ," MainMenu.mlx" ,proj ,Flag= " Close" )
7- MoveFilesAround(" R2023b" ," README.mlx" ,proj ,Flag= " Close" )
8- % MoveFilesAround("R2024a","UsingMATLABwithPython.mlx",proj,Flag="Close")
9- % MoveFilesAround("R2024a","CheckingTheWeather.mlx",proj,Flag="Close")
10-
11- end
12-
13- function MoveFilesAround(ReleaseString ,FileString ,proj ,opts )
14- arguments
15- ReleaseString (1 ,1 ) string {mustBeRelease }
16- FileString (1 ,1 ) string {mustLookLikeFile }
17- proj
18- opts.OldStr (1 ,1 ) string = " Old"
19- opts.NewStr (1 ,1 ) string = " New"
20- opts.Flag (1 ,1 ) string {mustBeMember(opts .Flag ,[" Open" " Close" ])} = " Open"
21- end
22-
23- if ~contains(ReleaseString ," R" )
24- ReleaseString = " R" +ReleaseString ;
25- end
26- [FileLoc ,FileName ,FileExt ] = fileparts(which(FileString ));
27-
28- if isMATLABReleaseOlderThan(ReleaseString )
29- FileStringOld = FileName + opts .OldStr + FileExt ;
30- FileStringNew = FileName + opts .NewStr + FileExt ;
31- FileString = string(FileName )+FileExt ;
32- try
33- if opts .Flag == " Open"
34- if exist(fullfile(proj .RootFolder ," Utilities" ," OldVersions" ,FileStringOld )," file" )
35- movefile(fullfile(FileLoc ,FileString ), fullfile(" Utilities" ," OldVersions" ,FileStringNew ))
36- movefile(fullfile(" Utilities" ," OldVersions" ,FileStringOld ),fullfile(FileLoc ,FileString ))
37- end
38- else
39- if exist(fullfile(proj .RootFolder ," Utilities" ," OldVersions" ,FileStringNew )," file" )
40- movefile(fullfile(FileLoc ,FileString ), fullfile(" Utilities" ," OldVersions" ,FileStringOld ))
41- movefile(fullfile(" Utilities" ," OldVersions" ,FileStringNew ),fullfile(FileLoc ,FileString ))
42- end
43- end
44- catch
45- disp(" Failed to move " + FileString + " ." )
46- end
47- end
48- end
49-
50- function mustBeRelease(str )
51- if ~contains(str ," R" )
52- str = " R" +str ;
53- end
54- pattern = " R" +digitsPattern(4 )+(" a" |" b" );
55- assert(matches(str ,pattern )," ReleaseString must be a valid MATLAB release." )
56- end
57-
58- function mustLookLikeFile(str )
59- [~ ,f ,e ] = fileparts(str );
60- assert(~isempty(f ))
61- assert(e ==" .mlx" |e ==" .m" |e ==" .slx" )
62- end
1+ % function ProjectShutdown
2+ % % Reset module to original state that is expected when loading in a new
3+ % % MATLAB version.
4+ % proj = currentProject;
5+ %
6+ % MoveFilesAround("R2023b","MainMenu.mlx",proj,Flag="Close")
7+ % MoveFilesAround("R2023b","README.mlx",proj,Flag="Close")
8+ % % MoveFilesAround("R2024a","UsingMATLABwithPython.mlx",proj,Flag="Close")
9+ % % MoveFilesAround("R2024a","CheckingTheWeather.mlx",proj,Flag="Close")
10+ %
11+ % end
12+ %
13+ % function MoveFilesAround(ReleaseString,FileString,proj,opts)
14+ % arguments
15+ % ReleaseString (1,1) string {mustBeRelease}
16+ % FileString (1,1) string {mustLookLikeFile}
17+ % proj
18+ % opts.OldStr (1,1) string = "Old"
19+ % opts.NewStr (1,1) string = "New"
20+ % opts.Flag (1,1) string {mustBeMember(opts.Flag,["Open" "Close"])} = "Open"
21+ % end
22+ %
23+ % if ~contains(ReleaseString,"R")
24+ % ReleaseString = "R"+ReleaseString;
25+ % end
26+ % [FileLoc,FileName,FileExt] = fileparts(which(FileString));
27+ %
28+ % if isMATLABReleaseOlderThan(ReleaseString)
29+ % FileStringOld = FileName+opts.OldStr+FileExt;
30+ % FileStringNew = FileName+opts.NewStr+FileExt;
31+ % FileString = string(FileName)+FileExt;
32+ % try
33+ % if opts.Flag == "Open"
34+ % if exist(fullfile(proj.RootFolder,"Utilities","OldVersions",FileStringOld),"file")
35+ % movefile(fullfile(FileLoc,FileString), fullfile("Utilities","OldVersions",FileStringNew))
36+ % movefile(fullfile("Utilities","OldVersions",FileStringOld),fullfile(FileLoc,FileString))
37+ % end
38+ % else
39+ % if exist(fullfile(proj.RootFolder,"Utilities","OldVersions",FileStringNew),"file")
40+ % movefile(fullfile(FileLoc,FileString), fullfile("Utilities","OldVersions",FileStringOld))
41+ % movefile(fullfile("Utilities","OldVersions",FileStringNew),fullfile(FileLoc,FileString))
42+ % end
43+ % end
44+ % catch
45+ % disp("Failed to move " + FileString + ".")
46+ % end
47+ % end
48+ % end
49+ %
50+ % function mustBeRelease(str)
51+ % if ~contains(str,"R")
52+ % str = "R"+str;
53+ % end
54+ % pattern = "R"+digitsPattern(4)+("a"|"b");
55+ % assert(matches(str,pattern),"ReleaseString must be a valid MATLAB release.")
56+ % end
57+ %
58+ % function mustLookLikeFile(str)
59+ % [~,f,e] = fileparts(str);
60+ % assert(~isempty(f))
61+ % assert(e==".mlx"|e==".m"|e==".slx")
62+ % end
0 commit comments