Tech Articles


Grid datawindow object with variable number of columns


Here is a way to build a grid datawindow which contains columns corresponding to an unknown number of data elements. You could use this approach in creating a project schedule, inventory location system, baseball box score, or any number of other examples. My example assumes the minimum number of columns to be four.

This create grid event returns a string.

long    ll_columns, ll_count, ll_pos
string ls_errors, ls_sql, ls_dw_presentation, ls_dw_syntax, ls_find, ls_name, ls_mod_string
// base presentation information
ls_dw_presentation =    "style( type=Grid                          &
            Horizontal_spread = 25 )            &
     datawindow( units=1                       &
             Color= 16777215)              &
     column( Font.Face='Arial'         &
         Font.Height=-9                    &
         Font.Weight=400)                  &
         text(   Font.Face='Arial' &
         Font.Height=-9                    &
         Font.Weight=400                   &
             Border=6)"

Read more

Trapping DataWindow Control System Commands


Perhaps you’ve enabled the titlebar and control menu of a DataWindow control.  You may even want the users to be able to minimize/maximize and reposition the control at runtime.

DataWindow Control Properties

Now you’d like to trap when the user interacts with the control in this fashion in order to execute some logic when they do. Perhaps you’d like to know when/if the user closes the DataWindow control.

Read more

The dwSyntax Tool


Thank you Sandy Barletta!

Just after the earth began to cool (I think it was in the PB3 time frame), I discovered the DWSyntax tool created by Sandy.

‘Round about that time I had been exporting DataWindow objects (this was before “edit source” folks) in order to get functional syntax for my dwModify() calls. Lo’ and behold I discovered this nifty GUI that would allow me to browse the dwDescribe(), dwModify(), SyntaxFromSQL() argument syntax for any DataWindow item or for the DataWindow object itself.

Fast forward to the present day. Let’s say you need to change the expression of a computed field at runtime, much as I illustrated in another tip on dynamically “creating” DataWindow groups.

From the PowerBuilder IDE, open the “New” dialogue. Select the “Tool” tabpage, and then select the “DataWindow Syntax” item.

Image

 

Read more

Dynamic Runtime DataWindow Group Creation


Here’s a DataWindow tip…and a half.

Unless you want to dynamically build a DataWindow object from scratch at runtime (it’s do-able…but quite involved), there’s no direct way to create a group for a DataWindow object in an ad hoc manner. Here’s a workaround.

First, insert a computed field in an extant DataWindow object and give it an expression that’s an empty string. For the sake of this tip the computed field’s name will be “dynamicgroup”.

image

 

 

Read more

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.

Read more

Fast String Concatenation


I needed a way to build a string in a loop for import into a DataWindow but speed was important.

I created an object with functions that allows for string concatenation using a blob variable that is allocated once and no external function calls are needed.

To test my object I concatenated a string of 445 characters to a new string 500 times. The standard method seen here took 320 milliseconds:

ls_data = "-start-"
For li_idx = 1 To 500
	ls_data = ls_data + "-" + String(li_idx) + "-"
	ls_data = ls_data + is_string
Next

The test using my object seen here took only 20 milliseconds:

n_stringclass sc

sc.alloc(225000)
sc.copy("-start-")
For li_idx = 1 To 500
	sc.concat("-" + String(li_idx) + "-")
	sc.concat(is_string)
Next
ls_data = sc.value()
Read more

Sorting a string array


I had a need to sort a string array and I found some code on Real Gagnon’s website that sorted numbers by creating a DataStore/DataWindow on the fly and used that to sort. Someone added a comment that for strings you need to define the column as char to avoid errors. I improved the code by adding a loop to determine the longest string in the array and using that when defining the DataWindow source.

 

public function boolean of_sortarray (ref string as_array[], string as_order);// —————————————————————————–

// SCRIPT:     of_SortArray

//

// PURPOSE:    This function sorts the passed array using a DataStore created

// on-the-fly.

//

// This is based on code from Real Gagnon:

// http://www.rgagnon.com/pbdetails/pb-0114.html

//

// ARGUMENTS:  as_array – Array of values to sort

// as_order – The sort order:

//

// Order value Resulting sort order

// ———————— —————————

// a, asc, ascending, ai, i Case-insensitive ascending

// d, desc, descending, di Case-insensitive descending

// as, s Case-sensitive ascending

// ds Case-sensitive descending

//

// DATE        PROG/ID DESCRIPTION OF CHANGE / REASON

// ———-  ——– —————————————————–

// 09/27/2016 RolandS Initial Coding

// —————————————————————————–

 

Read more

Find Articles by Tag

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