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

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