getFolder.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. % getFolder
  2. %
  3. % Similar to uigetdir except that it will remember the location of the
  4. % last opened folder.
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. % Use plotAverageWaveforms
  8. %
  9. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  10. % Kian Torab
  11. % ktorab@blackrockmicro.com
  12. % Blackrock Microsystems
  13. % Salt Lake City, UT
  14. %
  15. % Version 1.0.0.0
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17. function dataFolder = getFolder
  18. settingFileFullPath = getSettingFileFullPath('getFolder');
  19. %% Opens the getFolder.ini file to see what the last accessed folder was
  20. if exist(settingFileFullPath, 'file') == 2
  21. settingsFID = fopen(settingFileFullPath, 'r');
  22. defaultOpenLocation = fscanf(settingsFID, '%200c');
  23. fclose(settingsFID);
  24. else
  25. defaultOpenLocation = [];
  26. end
  27. %% Gets a folder by opening the last accessed folder as the last location
  28. dataFolder = uigetdir(defaultOpenLocation);
  29. %% Saves the last opened folder in the getFolder.ini file for later use
  30. if ischar(dataFolder)
  31. settingsFID = fopen(settingFileFullPath, 'w');
  32. fprintf(settingsFID, '%s', dataFolder);
  33. fclose(settingsFID);
  34. end