{"id":243,"date":"2010-07-27T20:20:24","date_gmt":"2010-07-28T01:20:24","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=243"},"modified":"2021-03-09T01:34:55","modified_gmt":"2021-03-09T06:34:55","slug":"powerbuilder-user-customization-service","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-user-customization-service\/","title":{"rendered":"PowerBuilder &#8211; User Customization Service"},"content":{"rendered":"<p>Here is an easy to implement user customization service you can add to your Powerbuilder applications which stores configuration information in a database. This gives the added benefit of portability to the users as nothing is stored in files or the registry. It is PFC based but, with minor modifications, could be un-coupled from that if desired.<\/p>\n<p>The main object is the n_cst_dbinifile NVO. The export of it can be downloaded from here. <a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/07\/n_cst_dbinifile.zip\">n_cst_dbinifile<\/a><br \/>\nNote the export makes use of the PFC n_cst_inifile NVO but this can be stripped out if desired.<\/p>\n<p>The service allows for default values to be set up and used if the user does not have their own set up (or when you give them the option to undo all their changes). The service also keeps itself updated by retrieving the datastore at an interval of your choosing.<\/p>\n<p>Database table (SQL Server)<br \/>\nYou will need the following table added to your database:<\/p>\n<pre name=\"code\" class=\"SQL\">create table cmnIniFile (\nfileName varchar(255) NULL,\nuserCode varchar(255) NULL,\nsectionName varchar(32) NULL,\nkeyName varchar(255) NULL,\nvalusString varchar(8000) NULL\n)<\/pre>\n<p>The dataobject is called d_dbinifile and has two retrieval args:<br \/>\nas_filename (string)<br \/>\nas_userCode (string)<\/p>\n<p>The SQL for the dataobject is:<\/p>\n<pre name=\"code\" class=\"SQL\">SELECT cmnIniFile.filename,\n         cmnIniFile.userCode,\n         cmnIniFile.sectionName,\n         cmnIniFile.keyName,\n         cmnIniFile.valueString\n    FROM cmnIniFile\n   WHERE ( cmnIniFile.filename = :as_filename ) AND\n         ( ( cmnIniFile.userCode = :as_userCode ) OR\n         ( cmnIniFile.userCode = &#039;DEFAULT&#039; ) )\nORDER BY cmnIniFile.filename ASC,\n         cmnIniFile.userCode ASC,\n         cmnIniFile.sectionName ASC,\n         cmnIniFile.keyName ASC<\/pre>\n<p>Implementation<\/p>\n<p>In the application manager object (n_cst_appmanager) for the application you need:<\/p>\n<p>n_cst_dbIniFile inv_userIniFile \/\/ instance variable<\/p>\n<p>and a method (of_create_ini) which is called as part of application start up.<\/p>\n<pre name=\"code\" class=\"VB\">long ll_rc\nstring ls_appName\nls_appName = of_getAppName () \/\/set in constructor by of_setappname method\n\ninv_userIniFile = create n_cst_dbIniFile\nll_rc = inv_userIniFile.of_register (SQLCA, ls_appName, gs_username) \/\/gs_username set at log in\nif ll_rc &lt; 0 then\n\tmessagebox (&quot;Application Open Error&quot;, &quot;Unable to register the user&#039;s DB INI file.&quot;)\nend if\nreturn ll_rc<\/pre>\n<p>In the destructor event of the app manager object you should destroy the inv_userIniFile object.<\/p>\n<p>In various windows with user specified settings which you wish to implement:<\/p>\n<pre name=\"code\" class=\"VB\">string ls_flag\nls_flag = gnv_app.inv_userIniFile.of_getString(&#039;Defaults&#039;,&#039;Maximized&#039;,&#039;N&#039;)\/\/ arguments: section, value, default\n\/\/ do some processing based on the ls_flag value\n\/\/ get another setting\nls_flag = gnv_app.inv_userIniFile.of_getString(&#039;Defaults&#039;,&#039;Grid Order&#039;,&#039;N&#039;)\n\/\/ do some other processing based on the ls_flag value<\/pre>\n<p>Now we want to save settings (window size and position in this example)<\/p>\n<pre name=\"code\" class=\"VB\">gnv_app.inv_userIniFile.of_setString(this.title, &#039;xpos&#039;, string(this.X))\ngnv_app.inv_userIniFile.of_setString(this.title, &#039;ypos&#039;, string(this.Y))\ngnv_app.inv_userIniFile.of_setString(this.title, &#039;height&#039;, string(this.height))\ngnv_app.inv_userIniFile.of_setString(this.title, &#039;width&#039;, string(this.width))<\/pre>\n<p>In general this would be done as part of the window close event.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is an easy to implement user customization service you can add to your Powerbuilder applications which stores configuration information in a database. This gives the added benefit of portability to the users as nothing is stored in files or the registry. It is PFC based but, with minor modifications, could be un-coupled from that&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/243"}],"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=243"}],"version-history":[{"count":13,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":1773,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/243\/revisions\/1773"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}