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

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