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

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