The BAPBUG Journal
Issue #3, September 1998




Welcome from our President
By Debbie Arczynski


Meeting Information


PowerTimes Available to BAPBUG Members


Member Notes

    Crosstab datawindows

    A 2-Dimensional Drop Down List Box

By Greg Dzingeleski


Efficient Assignment of Colors in PowerBuilder on the Windows Platform

By Robin Bates


Contact List


Welcome from our President

Welcome to the Baltimore Area PBUG newsletter. Each issue will hopefully contain insights and helpful tips and techniques that should help you on your way to developing exceptional PowerBuilder applications

This newsletter is YOUR newsletter! We hope that it is stimulating and helps you in your quest for the answer to the ultimate PowerBuilder question that you have on your mind! By the way, what is your question? You can forward all questions to any of the technical advisors. They are there for you. Their phone numbers and email addresses are listed in the newsletter, along with all of the BAPBUG officers.

Please feel free to contact any of the officers if you have suggestions of topics for our bi-monthly meetings, concerns with the running/editing of the meetings or newsletter, or just comments in general.

We also want to encourage you to submit small, medium, or large articles of interest to the PowerBuilder community along with any "PowerBuilder tips" that have helped you along your way and may help others.

We want to thank Greg Dzingeleski for volunteering to take on the enormous task of organizing and putting together this newsletter. Thanks Greg!

We hope to see you at our next meeting in October, and hope to hear from you soon!

Debbie Arczynski


August Meeting

Many thanks to Fred Grau for presenting "PFC Tips and Techniques", and to Debbie Arczynski for presenting "PFC or not PFC". Both Fred and Debbie are officers of BAPBUG, and we want to thank them for their time and effort.

Next Meeting

Our next meeting is Wednesday, October 7 at the OAG building at SSA. It will consist of several presentations. Anne Sola will be presenting "PowerBuilder and the Year 2000". Mark Pfeifer will be presenting "The Future Direction of Sybase". These presentations divulge some of the information obtained at the training classes that were available at the PowerSoft Conference in Los Angeles in August. There will also be several "give-away"s at this meeting, so please feel free to join us for some exhilarating and simulating discussions.

Future Meetings

David Wolf from Sybase will be at the December meeting to present "Building Good Components". This presentation will describe how to architect your PowerBuilder applications for 3-tier computing. It is basically a 12 step program to developing true Client-Server applications. Hope you can make it.

Interested in speaking at a future user group meeting?

If you are interested in speaking on a particular subject, or would like to demo your PowerBuilder application that you have been working on, please contact Debbie Arczynski at (410) 796-9461 (or debbie@charm.net). There are openings for presentations or demos of any length from 10 minutes to 2 hours. Thanks!

BAPBUG Web Page

Please take a look at our new web page designed by Anne Sola. It has lots of information about the group itself, the officers, the agenda, events, jobs, and links to other PB web pages. It is located at: www.geocities.com/siliconvalley/bay/8680. If you have any suggestions and/or comments, please contact Anne Sola.


PowerTimes Available to BAPBUG Members

PowerTimes is a bi-monthly publication written by and for the professional PowerBuilder community. Corporate Technology Partners, Inc. is proud to sponsor this valuable, cutting-edge resource for all BAPBUG members. At CTP, we understand the need to stay ahead of the curve on existing and emerging technologies in order to best help our clients realize profitable IT solutions. Share the CTP commitment and enjoy your free annual subscription by visiting www.ctpartners.com/asp/powertimes.asp.




MEMBER NOTES

Crosstab Datawindows

In the datawindow painter you get progress messages as a crosstab report is being calculated (the messages are 'Calculating crosstab columns.', 'Calculating crosstab rows.', 'Populating crosstab.' and 'Building crosstab.'). These messages may be captured programmatically and used for microhelp or any other uses. To capture these messages map a datawindow user event to the pbm_dwnMessagetext event. The text argument of this event contains the progress messages for the crosstab calculation.

A 2-dimensonal drop down list box

A drop down list box is a handy way to give users a choice of values to enter in a field, but it can get cumbersome if the number of choices is large. One solution is to use the PFC drop down datawindow search feature which will search for the correct entry as the user types data into the field. One problem with this is that the user needs to know the correct entry and another is that it requires the user to switch from a mouse to the keyboard. As we all know this can cause severe user trauma involving long hospital stays and can also cause erratic behavior in analysts and managers. In certain situations a 2-dimensional drop down datawindow may solve the problem. A one dimensional drop down datawindow has one item on each line (perhaps with a description

following it). A two dimensional drop down datawindow will have the available items in a grid as shown here. (If you didn't already know, I'm making these terms up as I go). This sort of presentation style might be useful for the entry of a single character code or maybe a list of states. Unfortunately, it does have the disadvantage of offering no description for each item.

I had very little trouble creating this drop down datawindow. I can't take personal credit for this, I must attribute this to Powerbuilder and how well the datawindow works. The datawindow for this was created as a N-up presentation with 6 columns. I used an external data source of one string column of one space named thingy. The resulting datawindow has 6 columns named thingy_1 through thingy_6. I put data into the datawindow and saved it so I don't have to do that programatically.

 

The only tricky part, which turned out to not be tricky, is when you associate the datawindow with a column. I specified a drop down datawindow edit style and associated my new datawindow. Next I have to associate the column, but I can't tell if the user is going to click on column thingy_1 or thingy_3 so I don't know which one to associate with the data for the field. However, the column list has entries for thingy_6 through thingy_1 but then it has an entry named thingy. I chose this one for the display column and the data column and everything worked out as I wanted. The data from whatever column the user clicks on is entered into the field. One bit of odd behavior/bug/feature is that the text for the currently selected item is changed to white. In this example I just made the background grey so you can still see it. I'll leave it as an exercise for the reader to determine how to control this. Mostly because I don't have time to play with it right now. If you figure it out send me a message and I'll put it in the next newsletter.

Greg Dzingeleski, Ph.D., Social Security Administration

greg.dzingeleski@ssa.gov


Cook up your own Java development solutions at the Fall '98 Java


Developer Kitchen, put on by Sybase, Sun Microsystems, and Nova Labs!

This Kitchen offers two full-day, comprehensive technical tracks:

Enterprise JavaBeans on day one, and/or Writing Server Side Java Using

Servlets on day two. Come to one track or both, only $249 per day!

Check out Sybase at the Enterprise JavaBeans in-depth track. We'll show

you how to quickly develop and deploy Enterprise JavaBeans using PowerJ

and our newly introduced Enterprise Application Studio, then deploy them

to the Sybase Enterprise Application Server. We'll also preview some of

the exciting new Enterprise JavaBeans features coming in the next

release of Enterprise Application Studio!

Every attendee will receive over $200 in free software-including a

chance to win a FREE copy of Sybase's PowerJ during the Enterprise

JavaBeans track! The Developer Kitchen will be touring 12 cities in the

US and Canada. Seating is limited, so register today.

For agenda details, dates, locations and registration, visit

http://www.nova-labs.com or call 732-263-9000.


Efficient Assignment of Colors in PowerBuilder on the Windows Platform

The assigning of colors within PowerBuilder can occur in any of three ways. Colors may be (1) set statically in the painters, (2) dynamically in methods (function and events) in PowerScript (and probably through the Operating System’s SDK through external function calls) and (3) with the use of conditional expressions for DataWindow objects’ bands and components called "dwobjects".

Static Assignment of Color

When we assign color properties (text color and background, line and fill, or background) from within the graphic painters (as opposed to within the script painter) we are presented with a list of fixed colors, four window environment colors, and as many as 4 "custom colors". Within the DataWindow Object painter, we can also choose transparent (but that is really a second property "Background.Mode" which takes a value of zero for opaque and one for transparent, and not an actual "Background.Color").

The Custom Colors allow for a choice of four colors from a developer set palette of 16 colors. The developer can set up these colors by choosing Custom Colors… from the dropdown menu under the Design menu item on the menu bar in the Window, DataWindow Object or User Object painters. Custom Colors are usually selected to infuse the application with recognizable shades of colors that the client uses in its logo and for public relations purposes. For example, Sybase has a special shade of teal and of purple that it requires for its certified instructors’ logo if any color is used.

Unless charged to use Custom Colors by the client it is often good to rely mainly on the four windows environmental colors when statically assigning color properties of objects in the graphical painters. Window Text, Button Face, Application Workspace and Window Background are color assignments which allow the end-users’ subsequent color scheme choices to appear in your deployed application at run time. This allows for a more user customizable application reflecting their choosen color scheme and potentially increasing their satisfaction with your PowerBuilder application. The less mainstream their taste in color, the potential greater satisfaction they will have in your application accepting their palette of colors.

Dynamic Color Assignment

When we dynamically assign color values in PowerBuilder functions and events using PowerScript, we assign a long value to a property of an object or a control. Traditionally, the source of that assignment is the system function, RGB() which returns a long. This function takes 3 integers as arguments, one each for the red, the green and the blue color components to produce the desired "additive" color value. These integers should take values within the range of 0 and 255 inclusively and the function computes The formula for combining the colors is

Red * 2560 + (Green * 2561) + (Blue * 2562)

which may also be written as

Red + (256 * Green) + (65536 * Blue).

Since this is an "additive" color system a maximum value, 255, for all three components results in white (all CRT guns or LCD panel pixels firing) and the minimum value, 0, results in black.

As PowerBuilder developers, we can also do the calculations ourselves and assign the long numeric value rather than use the RGB() function. The compiler will check to make sure that we are assigning a number to the color property we are setting in our script. But, if we don’t want to hardcode actual numbers throughout our script, we can declare constants of type long with meaningful names and accurate values. To aid in that process, I have included all of the component red, green and blue integer values as well as the final long value for every documented named color that I located in the Sybase documentation. I also included the colors offered in the graphical painters’ dropdown picture listboxes. Except that I did not reverse engineer the component values for the four Windows scheme colors. You may note that Sybase calls the same numeric color value both "olive" and "brown". Also, since the numeric value is different for "green" in their documentation than it is in the dropdown picture listbox, I have called the green on the dropdown picture listbox, "dark_green".

I have gathered these long color constants together as the instance constants (instance variables that do not vary) of a custom class user object (aka NVO) that can be declared as a global variable. I recommend naming your global reference variable of this class of NVO, "GC" (for "global constants"). With this NVO class in a PBL in your application’s library search path and a declared global variable called GC, you can then use dot notation to assign colors to object properties throughout you application’s scripts.

 

This.BackColor = GC.Fuchsia

During compilation, the compiler will substitute the actual numeric value for the constant in the NVO for the reference. The end result being as if you hardcoded literals in your assignment statements. If you want to extend the NVO’s instance constants with your own you would now have a central place to put those new constants. Such additional constants could be other custom colors or constants that have nothing at all to do with colors or even with the appearance of your application’s GUI. Constants are the closest PowerBuilder developer can currently get to declaring enumerated datatypes. Therefore they can aid in the readability and execution type efficiencies of your code.

When we assign colors conditionally through expressions for dwobjects and / or bands (header/s, detail, trailer/s, summary and footer) we may be tempted to use the Datawindow’s RGB() function (functionally equivalent to the system level RGB() function) within an IF() or Case() statement. This approach will cause an avoidable performance penalty. Although the DWSyntax utility which accompanies PowerBuilder has a RGB "calculator" it will not provide the developer with the final long numeric value the RGB() function returns when given the three color arguments. The use of the RGB() function in a DataWindow Object band or dwobject will result in it being executed for each and every occurance of that band or dwobject within the DataWindow object. If you know what the long values for the colors that you need are in advance you can substitute them for the RGB() function, speeding up your application. You cannot directly use the constants in the global NVO, but you can hardcode the numeric values from their declarations.

Let me add one final note on numeric values for Button Face, Window Text, Window Background, and Application Workspace (the four Windows scheme colors). They are not the only values that work to generate these Windows colors, other numeric values will have the same result. I got these values by placing objects in a window in the painter using these dropdown listed color values and then asking them in PowerScript to report on their color values, getting back the numbers that I assigned in the NVO’s constants.

What follows is the exported N_CST_Constants from my library painter;

$PBExportHeader$n_cst_constants.sru

$PBExportComments$color constants and RGB() conversion values - 2/27/98 - by robin.bates@powercerv.com, an Advanced CPI & CPD-Professional To use declare a global variable in your application N_CST_CONSTANTS GC , Then in your PowerScript use GC.color_name

forward

global type n_cst_constants from nonvisualobject

end type

end forward

global type n_cst_constants from nonvisualobject

end type

global n_cst_constants n_cst_constants

type variables

Constant Long Black = 0 // RGB( 0, 0, 0)

Constant Long Dark_Red = 128 // RGB( 128, 0, 0)

Constant Long Maroon = 128 // RGB( 128, 0, 0) - on dropdown

Constant Long Light_Red = 192 // RGB( 192, 0, 0)

Constant Long Red = 255 // RGB( 255, 0, 0)

Constant Long Dark_Green = 32768 // RGB( 0, 128, 0) - "Green" on dropdown

Constant Long Brown = 32896 // RGB( 128, 128, 0)

Constant Long Olive = 32896 // RGB( 128, 128, 0) - on dropdown

Constant Long Green = 65280 // RGB( 0, 255, 0)

Constant Long Lime = 65280 // RGB( 0, 255, 0) - on dropdown

Constant Long Yellow = 65535 // RGB( 255, 255, 0)

Constant Long Dark_Blue = 8388608 // RGB( 0, 0, 128)

Constant Long Navy = 8388608 // RGB( 0, 0, 128) - on dropdown

Constant Long Dark_Magenta = 8388736 // RGB( 128, 0, 128)

Constant Long Purple = 8388736 // RGB( 128, 0, 128) - on dropdown

Constant Long Dark_Cyan = 8421376 // RGB( 0, 128, 128)

Constant Long Teal = 8421376 // RGB( 0, 128, 128) - on dropdown

Constant Long Dark_Gray = 8421504 // RGB( 128, 128, 128)

Constant Long Gray = 8421504 // RGB( 128, 128, 128) - on dropdown

Constant Long Light_Gray = 12632256 // RGB( 192, 192, 192)

Constant Long Silver = 12632256 // RGB( 192, 192, 192) - on dropdown

Constant Long Mint = 12639424 // RGB( 192, 220, 192) - on dropdown

Constant Long Sky = 15780518 // RGB( 166, 202, 240) - on dropdown

Constant Long Cream = 15793151 // RGB( 255, 251, 240) - on dropdown

Constant Long Blue = 16711680 // RGB( 0, 0, 255)

Constant Long Fuchsia = 16711935 // RGB( 255, 0, 255) - on dropdown

Constant Long Magenta = 16711935 // RGB( 255, 0, 255)

Constant Long Aqua = 16776960 // RGB( 0, 255, 255) - on dropdown

Constant Long Cyan = 16776960 // RGB( 0, 255, 255)

Constant Long White = 16777215 // RGB( 255, 255, 255)

Constant Long Window_Text = 33554432

Constant Long WndText = 33554432 // - on dropdown

Constant Long Button_Face = 79741120

Constant Long ButtonFace = 79741120 // - on dropdown

Constant Long Application_Work_Space = 275800223

Constant Long AppWrkSpc = 275800223 // - on dropdown

Constant Long Window_Background = 1073741824

Constant Long WndBkrnd = 1073741824 // - on dropdown

end variables

on n_cst_constants.create

TriggerEvent( this, "constructor" )

end on

on n_cst_constants.destroy

TriggerEvent( this, "destructor" )

end on

Author – Robin Bates is a SCI (Sybase Certified Instructor) in the "Advanced Tools Curriculum", a CPD-Professional, a Technical Advisor for BAPBUG and its past president and its founder. He has been a programmer/developer for about 2 decades. He resides in Manchester, MD in Carroll county and when he is not out of town teaching PowerBuilder usually commutes to the U. S. Treasury in Hyattsville, MD as a consultant for PowerCerv. He can be reached at cpdp@erols.com or robin.bates@powercerv.com


Contacts

BAPBUG Officers
President Debbie Arczynski debbie@charm.net (410) 796-9461
Vice President Bill Bitman bitman@jhuapl.edu (410) 792-6000
Secretary Gordon Giffen gordon-g@vips.com (410) 832-8300
Treasurer Fred Grau fred1@flash.net (410) 893-9638
Tech Advisor Robin Bates robin.bates@powercerv.com (703) 502-8383
Tech Advisor Susan Galli susan@annopolis.net (410) 987-2684
Tech Advisor Mark Pfeifer mpfeifer@sprynet.com (410) 499-8765
Web Co-ordinator Anne Sola anne-s@vips.com (410) 832-8300
Newsletter Editor Greg Dzingeleski greg.dzingeleski@ssa.gov (410) 966-3328

Back to Home Page

1