NPMKverChecker.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. function NPMKverChecker()
  2. % NPMKverChecker
  3. %
  4. % Checks to see if there is a newer version of NPMK is available for
  5. % download.
  6. %
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. % Use NPMKverChecker
  9. %
  10. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11. % Kian Torab
  12. % support@blackrockmicro.com
  13. % Blackrock Microsystems
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15. % Version History
  16. %
  17. % 1.0.0.0: September 13, 2017
  18. % - Initial release.
  19. %
  20. % 1.0.1.0: September 13, 2017
  21. % - Fixed a crash in case there is no Internet connection.
  22. %
  23. % 1.0.2.0: January 10, 2018
  24. % - Added a clickable URL to the prompt.
  25. %
  26. % 1.1.0.0: January 27, 2020
  27. % - Only checks for a new version once a week instead of every time.
  28. %
  29. % 1.2.0.0: August 13, 2020
  30. % - Updated to use settingsManager instead.
  31. %
  32. % 1.3.0.0: September 11, 2020
  33. % - Fixed a bug that was still creating a NPMKverChecker.dat.
  34. %% Variables and constants
  35. gitHubURL = 'https://github.com/BlackrockMicrosystems/NPMK/releases/latest';
  36. checkver = 0;
  37. %% Check for the latest version fo NPMK
  38. try
  39. NPMKSettings = settingsManager;
  40. if floor(abs(now - datenum(NPMKSettings.checkeddate - days(1)))) > 8
  41. checkver = 1;
  42. end
  43. if checkver
  44. FIDv = fopen('Versions.txt');
  45. verFile = fscanf(FIDv, '%s');
  46. fclose(FIDv);
  47. latestVersion = verFile(findstr('LATEST', verFile)+7:findstr('LATEST', verFile)+13);
  48. gitHubPage = urlread(gitHubURL);
  49. newVersionAvailable = findstr(latestVersion, gitHubPage);
  50. if isempty(newVersionAvailable)
  51. disp('A new version of NPMK may be available.');
  52. fprintf('Please visit <a href="%s">GitHub NPMK Page</a> to get the latest version.\n', gitHubURL)
  53. end
  54. NPMKSettings.checkeddate = datetime;
  55. settingsManager(NPMKSettings);
  56. end
  57. catch
  58. end