{"id":2511,"date":"2010-01-01T13:07:37","date_gmt":"2010-01-01T13:07:37","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/01\/uiputfile2\/"},"modified":"2010-01-04T20:07:46","modified_gmt":"2010-01-04T20:07:46","slug":"uiputfile2","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/01\/uiputfile2\/","title":{"rendered":"uiputfile2"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><b>Happy New Year!<\/b><\/p>\r\n   <\/introduction>\r\n   <div>\r\n      <ul>\r\n         <li><i>Wow - 2010. It's a whole new decade.<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/5021\">Bob<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9312-uiputfile2\">uiputfile2<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/21403\">Chris Cannell<\/a>.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/uiputfile2.png\"> <\/p>\r\n   <p>This utility function is a wrapper to MATLAB's <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/uiputfile.html\">uiputfile<\/a><\/tt> command. What does it add? Memory. More specifically, it remembers the folder where the last file was saved. So when users\r\n      of your GUIs want to save files, they don't have to navigate to their favorite folders every time. Nice.\r\n   <\/p>\r\n   <p>Chris chose to implement <tt>uiputfile2<\/tt> by simply saving the information (path to folder) in a MAT file. That way it remembers from MATLAB session to session. That\r\n      strategy is also robust to upgrades. Sweet.\r\n   <\/p>\r\n   <p>I know I could program the logic myself, but thanks to Chris I don't have to!<\/p>\r\n   <p><a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2511#respond\">Comments?<\/a><\/p>\r\n   <h3>See also (2010-01-05 update)<a name=\"8\"><\/a><\/h3>\r\n   <p>As <a href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/01\/uiputfile2\/#comment-13373\">Aur&eacute;lien noted<\/a> in addition to <tt>uiputfile2<\/tt> Chris also posted <tt><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9521-uigetdir2\">uigetdir2<\/a><\/tt> as well as <tt><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9254-uigetfile2\">uigetfile2<\/a><\/tt>. They also are similar location-persistent wrappers to <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/uigetdir.html\">uigetdir<\/a><\/tt> and <tt><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/uigetfile.html\">uigetfile<\/a><\/tt> respectively.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_0b1ed4ee7f684497a025398f39221e7f() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='0b1ed4ee7f684497a025398f39221e7f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 0b1ed4ee7f684497a025398f39221e7f';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Robert Bemis';\r\n        copyright = 'Copyright 2009 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_0b1ed4ee7f684497a025398f39221e7f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.10<br><\/p>\r\n<\/div>\r\n<!--\r\n0b1ed4ee7f684497a025398f39221e7f ##### SOURCE BEGIN #####\r\n%%\r\n% *Happy New Year!* \r\n%%\r\n% * _Wow - 2010. It's a whole new decade._\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/5021 Bob>'s \r\n% pick this week is \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9312-uiputfile2 uiputfile2> \r\n% by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/21403 Chris Cannell>.\r\n%%\r\n% <<..\/images\/pick\/uiputfile2.png>>\r\n%%\r\n% This utility function is a wrapper to MATLAB's \r\n% |<https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/ref\/uiputfile.html uiputfile>|\r\n% command. What does it add? Memory. More specifically, it remembers the\r\n% folder where the last file was saved. So when users of your GUIs want to\r\n% save files, they don't have to navigate to their favorite folders every\r\n% time. Nice.\r\n%%\r\n% Chris chose to implement |uiputfile2| by simply saving the information\r\n% (path to folder) in a MAT file. That way it remembers from MATLAB session\r\n% to session. That strategy is also robust to upgrades. Sweet.\r\n%%\r\n% I know I could program the logic myself, but thanks to Chris I don't have\r\n% to!\r\n%%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2511#respond Comments?>\r\n\r\n##### SOURCE END ##### 0b1ed4ee7f684497a025398f39221e7f\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Happy New Year!\r\n   \r\n   \r\n      \r\n         Wow - 2010. It's a whole new decade.\r\n      \r\n   \r\n... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/01\/uiputfile2\/\">read more >><\/a><\/p>","protected":false},"author":46,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2511"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2511"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2511\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}