{"id":1504,"date":"2012-10-11T18:31:08","date_gmt":"2012-10-11T23:31:08","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=1504"},"modified":"2021-03-06T10:35:56","modified_gmt":"2021-03-06T15:35:56","slug":"powerbuilder-update-the-datawindow-object-definition-programatically","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-update-the-datawindow-object-definition-programatically\/","title":{"rendered":"PowerBuilder &#8211; Update the Datawindow object definition programatically"},"content":{"rendered":"<p>I&#8217;m doing some work on an application to aid in the mass update of various datawindow attributes.  It&#8217;s not rocket science since you are dealing with a series of text files and doing some basic &#8216;find and replace&#8217; operations.  However, if you have ever worked on a project which has been around for a while you will notice that datawindows do not get &#8216;migrated&#8217; when you upgrade to a newer version of PowerBuilder; the export syntax remains at the version in which the thing was last modified and saved.<\/p>\n<p>Now you might think that using the LibraryExport and LibraryImport methods will do the trick but you would be mistaken.  A newly imported datawindow object keeps the same version as when it was exported.<\/p>\n<p>To accomplish the task you need to use the datawindow CREATE method.<\/p>\n<pre name=\"code\" class=\"VB\">integer li_file, li\r\nstring ls_old_syntax, ls_importsyntax\r\n\/\/ old datawindow syntax saved to a file\r\nls_old_syntax = &#039;C:\\temp\\d_oldstuff.txt&#039;\r\n\/\/ open and read the file\r\nli_file = Fileopen(ls_old_syntax, TextMode!)\r\nFilereadex(li_file, ls_importsyntax)\r\n\/\/ remember to close the file\r\nFileClose(li_file)\r\n\/\/ check version of ls_importsyntax\r\nIF POS(ls_importsyntax, &#039;release 12.5;&#039;) &gt; 1 THEN\r\n   \/\/ its already new, leave it alone\t\t\r\nELSE\r\n   \/\/ dw_new is object on the window\r\n   dw_new.reset()\r\n   dw_new.dataobject = &#039;&#039;\r\n   \/\/ create the new datawindow object from the old syntax\r\n   li = dw_new.create(ls_importsyntax, ls_err) \r\n   \/\/ now get the new syntax\r\n   ls_new_syntax = dw_new.describe(&quot;DataWindow.Syntax&quot;)   \r\nEND IF<\/pre>\n<p>Now you can do whatever you want with the new syntax.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m doing some work on an application to aid in the mass update of various datawindow attributes. It&#8217;s not rocket science since you are dealing with a series of text files and doing some basic &#8216;find and replace&#8217; operations. However, if you have ever worked on a project which has been around for a while&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[21,12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1504"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=1504"}],"version-history":[{"count":3,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1504\/revisions"}],"predecessor-version":[{"id":1694,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1504\/revisions\/1694"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=1504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=1504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=1504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}