Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

getFile.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. function [dataFilename, dataFolder] = getFile(filterSpec, title)
  2. % getFile
  3. %
  4. % Similar to uigetfile, it opens a dialogue to get a file, but it also
  5. % remembers the last folder location, so the user will not need to navigate
  6. % to the same folder multiple times.
  7. %
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. % Use [dataFilename dataFolder] = getFile(filterSpec)
  10. %
  11. % filterSpec: The type of file to show. For example, if set to '*.txt'
  12. % (OPTIONAL) only text files will be visible for choosing.
  13. % DEFAULT: *.*, so all files are shown.
  14. %
  15. % title: This parameter will be the title of the dialogue box.
  16. % (OPTIONAL) DEFAULT: No title will be shown.
  17. %
  18. % dataFilename: The name of the chosen file.
  19. %
  20. % dataFolder: The path of the chosen file.
  21. %
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % USAGE EXAMPLE:
  24. %
  25. % [fileName pathName] = getFile('*.jpg');
  26. %
  27. % In this example a dialogue will open and only show all jpg files. The
  28. % name of the chosen file and the path to it are stores in fileName and
  29. % pathName respectively.
  30. %
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. % Kian Torab
  33. % ktorab@blackrockmicro.com
  34. % Blackrock Microsystems
  35. % Salt Lake City, UT
  36. % Contributors:
  37. %
  38. % Version 1.1.0.0
  39. % Last edit by: Kian Torab
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  41. % Version History
  42. %
  43. % 1.0.1.0:
  44. % - Initial release.
  45. %
  46. % 1.0.1.0:
  47. % - Minor update to the help and some formatting.
  48. %
  49. % 1.0.2.0: July 4, 2014
  50. % - Allows for selection of NSx files only.
  51. %
  52. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  53. if ~exist('filterSpec', 'var')
  54. filterSpec = '*.*';
  55. end
  56. if ~exist('title', 'var')
  57. title = '';
  58. end
  59. settingFileFullPath = getSettingFileFullPath('getFile');
  60. %% Opens the getFolder.ini file to see what the last accessed folder was
  61. if exist(settingFileFullPath, 'file') == 2
  62. settingsFID = fopen(settingFileFullPath, 'r');
  63. defaultOpenLocation = fscanf(settingsFID, '%200c');
  64. fclose(settingsFID);
  65. backDir = cd;
  66. if exist(defaultOpenLocation, 'dir') == 7
  67. cd(defaultOpenLocation);
  68. end
  69. [dataFilename, dataFolder] = uigetfile(filterSpec, title);
  70. cd(backDir);
  71. else
  72. [dataFilename, dataFolder] = uigetfile(filterSpec, title);
  73. end
  74. %% Saves the last opened folder in the getFolder.ini file for later use
  75. if ischar(dataFolder)
  76. settingsFID = fopen(settingFileFullPath, 'w');
  77. fprintf(settingsFID, '%s', dataFolder);
  78. fclose(settingsFID);
  79. end