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

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