Tech Articles


Updating the Datawindow Object Definition


I'm doing some work on an application to aid in the mass update of various datawindow attributes. It's not rocket science since you are dealing with a series of text files and doing some basic 'find and replace' 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 'migrated' 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.

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.

To accomplish the task you need to use the datawindow CREATE method.

integer li_file, li
string ls_old_syntax, ls_importsyntax
// old datawindow syntax saved to a file
ls_old_syntax = 'C:\temp\d_oldstuff.txt'
// open and read the file
li_file = Fileopen(ls_old_syntax, TextMode!)
Filereadex(li_file, ls_importsyntax)
// remember to close the file
FileClose(li_file)
// check version of ls_importsyntax
IF POS(ls_importsyntax, 'release 12.5;') > 1 THEN
   // its already new, leave it alone        
ELSE
   // dw_new is object on the window
   dw_new.reset()
   dw_new.dataobject = ''
   // create the new datawindow object from the old syntax
   li = dw_new.create(ls_importsyntax, ls_err) 
   // now get the new syntax
   ls_new_syntax = dw_new.describe("DataWindow.Syntax")   
END IF

Now you can do whatever you want with the new syntax.

Comments (0)
There are no comments posted here yet

Find Articles by Tag

Event CoderObject Authentication Android PostgreSQL ODBC driver MessageBox Encoding COM Configuration DataType DevOps PowerBuilder (Appeon) DataWindow Database Table Validation .NET Std Framework Database Connection Class InfoMaker OLE IDE Icon Database Profile Export Database Table Schema Design .NET DataStore PowerBuilder Windows 10 Icons Application DLL UI Themes Database Painter TLS/SSL JSONParser SOAP PBDOM Encryption Import JSON Deployment GhostScript Window Source Control Expression Repository Platform Array Menu Jenkins Outlook 64-bit Windows OS Debugger Resize Graph PowerBuilder Compiler SqlModelMapper Debug SnapDevelop PowerServer Web Variable Text SqlExecutor C# Web Service Proxy HTTPClient License DragDrop PBNI UI WinAPI Database Automated Testing Data Event Handling API Database Table Data Mobile DataWindow JSON Debugging Interface Transaction RibbonBar Event Handler RichTextEdit Control Source Code ODBC RibbonBar Builder Model PDF Service Azure Excel Export JSON PowerScript (PS) Charts NativePDF WebBrowser Database Object SDK PBVM XML iOS PowerServer Mobile Elevate Conference Bug Branch & Merge OAuth 2.0 .NET Assembly External Functions SnapObjects Web API Import PostgreSQL OAuth TortoiseGit SQL Server Syntax Messagging TFS REST JSON Open Source Sort File TreeView CrypterObject Migration Testing UI Modernization SQL CI/CD 32-bit Script Filter Oracle Error SVN Linux OS Installation Stored Procedure PFC JSONGenerator ActiveX Performance PDFlib Authorization BLOB OrcaScript RESTClient Visual Studio Git Trial