27 Apr 2009 @ 9:00 AM 

Download Source

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.

 

Accessing the DWSyntax Tool

 

From the tool’s menu, navigate to Syntax>Modify>Attributes.

Navigating the Tool's Menu

From the “Object” DDLB, choose “ComputedField”.

Choosing Computed Field Syntax

From the “Attributes” listbox, select “Expression”.

Selecting the 'Expression' Property

You’re then presented with two versions of the syntax’s template; one for Modify() call usage, the other if you prefer dot notation. Copy/paste the template syntax and replace the bracketed portions as appropriate with explicit values or with reference variables.

DWSyntax offers this functionality without breaking a sweat. To really start utilizing the power of the tool, browse its “create” syntax capabilities…

Syntax for the 'Create' Modify variant

…or its GUI have you build SyntaxFromSQL() syntax from scratch…

SyntaxFromSQL()

If you’re relatively new to PowerBuilder, you may find this tool to be instructive. If you’re an experienced PowerBuilder developer, I hope you enjoy the productivity this tool will provide.

Tags Tags: ,
Categories: Tips from the Field
Posted By: John Strano
Last Edit: 15 Apr 2009 @ 05 03 PM

EmailPermalinkComments (0)
 20 Apr 2009 @ 5:00 PM 

Greenbrier builds and leases railcars. When the company decided to develop customer interfaces for the Web it chose Sybase EAServer as their Web application server. EAServer gave Greenbrier the features it needed and seamless integration with PowerBuilder code made it the perfect tool to take its large library of PowerBuilder applications online.

(more…)

 
Tags Tags: ,
Categories: Success Stories
Posted By: John Strano
Last Edit: 16 Apr 2009 @ 05 25 PM

EmailPermalinkComments (0)

 Download Source

 

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”.

The Computed Field Expression

Then create a group based on this computed field.

A group based on the computed field.

A group based on the computed field.

 Format the DataWindow object according to your needs and save.

Now at runtime, modify the computed field’s expression to have the value of the column name by which you wish to group the result set.

 

dw_employees.setredraw( FALSE )

dw_employees.Modify(”dynamicgroup.Expression=’” + as_coltogroup + “‘” )

dw_employees.setsort( as_coltogroup + ” A”)

dw_employees.sort( )

dw_employees.groupcalc( )

dw_employees.setredraw( TRUE )

 

After calling SetSort() and Sort() to sort by the column on which you’re grouping, don’t forget to call GroupCalc() to recalculate the breaks in the groupings.

 

 Certainly this technique may be adapted to implement more than one grouping level. For those of you who maintain and enhance frameworks, the sample code fragment can certainly be made more generic as far as the reference to the DataWindow control and to the name of the computed field(s).

 

OK, here’s the half (.5) tip.

 

You’ve defaulted the value of the computed field’s expression to an empty string. This will work fine for grouping on columns of type string. However, for columns of other data types, you’ll need to invoke the DataWindow expression function String() to convert the non-string columns’ values to strings in order for the runtime modification to have the desired effect. Here’s how the accommodation appears in the sample code from earlier in this tip…

 

dw_employees.Modify(”dynamicgroup.Expression=’String(” + as_coltogroup + “)’” )

Tags Tags: ,
Categories: Tips from the Field
Posted By: John Strano
Last Edit: 07 Apr 2009 @ 06 19 PM

EmailPermalinkComments (0)

Download Source

 

 

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 Menu 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.

 

 The Control Menu UI

Go ahead and map a custom event for the DataWindow control to the pbm_syscommand Event ID.

Mapping the pbm_syscommand Event ID.

 

For purposes of demonstration, I’ve placed a singlelineedit control on a window and assigned the commandtype argument value of the event (an unsignedlong) as a string to the text property of the sle.

 

sle_commandtype.text = String ( commandtype )

 

In the screenshot, you can see that I’ve trapped the user clicking on the titlebar of the DataWindow control with a commandtype value of 61458. 

 

A commandtype value of 61458.

 

For your reference, I’ve included a roster of commandtype values here in this tip. Happy trapping!

 

61458: TitleBar Clicked

61456: “Move” invoked from Control Menu (cursor keys can move DW control)

61587: Control menu dropped down

61536: DataWindow Control Closed by Control Menu (or “X”)

61472: DataWindow Control is Minimized

61488: DataWindow Control is Maximized or resized by border interaction

61728: DataWindow Control size is “Restored”

 

61441: DataWindow Control is resized by left border interaction

61442: DataWindow Control is resized by right border interaction

61443: DataWindow Control is resized by top border interaction

61444: DataWindow Control is resized by NW corner interaction

61445: DataWindow Control is resized by NE corner interaction

61446: DataWindow Control is resized by bottom border interaction

61447: DataWindow Control is resized by SW corner interaction

61448: DataWindow Control is resized by SE corner interaction

Tags Tags: ,
Categories: Tips from the Field
Posted By: John Strano
Last Edit: 05 Apr 2009 @ 04 17 PM

EmailPermalinkComments (0)
\/ More Options ...
Change Theme...
  • Users » 91
  • Posts/Pages » 12
  • Comments » 0
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight