PowerBuilder ‘Gotcha’ – SyntaxFromSql and System Fonts

Posted on Thursday, July 12th, 2012 at 5:56 pm in

So a user of an application I work on is getting an error when opening a window which contains a dynamic datawindow. The open process reads a table and then dynamically creates a grid datawindowobject with the same number of columns as the data which is retrieved from the table. The process itself uses the datawindow syntax created from a SQL string and a presentation string via a SyntaxFromSql call and then a DW.Create call. In this one users case the process is returning a cryptic “datawindow release number is incorrect” message from the create.

Ah Ha! The user is running a Windows 7 workstation.
Ah Ha! The user doesn’t have the correct SQL Server native driver.
Ah Ha! The user has older PB runtime DLLs.

Nope, another Windows 7 workstation runs fine.
Nope, the driver is the same.
Nope, the runtimes are correct.

After setting up the window to create a text file containing the specific strings used to create the datawindow I see that a replace I am doing after it is generated by the SyntaxFromSql but prior to the Create is jumbling up the string. Now the reason it is jumbling it up is I assumed the value I was looking for was a static value and since the Pos method couldn’t find the proper place it came back with zero which tells the replace to start at the beginning of the string and screwed up the Release number.

I noticed a number of positional/size parameters were different in the two sets of files as well.

In Windows XP:

 release 12.5;
 datawindow(units=1 timer_interval=0 color=16777215
 processing=1 print.margin.bottom=24 print.margin.left=24
 print.margin.right=24 print.margin.top=24...

In Windows 7:

 release 12.5;
 datawindow(units=1 timer_interval=0 color=16777215
 processing=1 print.margin.bottom=30 print.margin.left=30
 print.margin.right=30 print.margin.top=30...

Notice the difference in the print.margin settings.

The datawindow presentation style is:

 "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           &

Which got me thinking about the font on the individual machines.

A post to the Sybase Powerbuilder Datawindow forum gave me the following:

Hi Matt;

I suspect you are correct when you say that the fonts are different.

The reason I say that is because the DWO settings for size &
displacement are set by the DW Painter. The DW Painter gets these at
regeneration / save time by using the IDE’s font settings. These in turn
are governed by the O/S’s “Default Printer”.

So, unless the XP and W7 PC are using the same default printer (and I am
talking about pointing to the exact network printer instance ) and have
the same recent printer font definitions installed (aka print driver
version) – then these type of minor variations would surface.

Now, when your PB application uses a SyntaxFromSQL () command, the same
default printer and font criteria is in play as if you were using the DW
Painter inside the IDE.


Regards … Chris
President: OSUG / STD Inc.
Vice President: ISUG
Blog: http://chrispollach.blogspot.com
SourceForge: http://sourceforge.net/projects/stdfndclass
PBDJ: http://chrispollach.sys-con.com

Thanks to Chris Pollach.

The ‘moral’ to this is you should explicitly set the various properties of the datawindow object after the create if you need to ensure a specific positional value is required to account for differences in user environments.

You might also be interested in