前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

Manning: PowerBuilder 6.0 Questions & Answers Home | Ordering Info | Shopping Cart Keep up with Manning for special offers and updates Receive our email newsletter Follow Manning on Twitter Become a Manning Facebook fan Catalog Java Microsoft & .NET All by Title All by Subject Mobile Formats Author Blogs Craig Walls iPhone in Action Peter Armstrong Andres Almiray David Black more... Author Calendar Manning Author Events About Manning Contact Us Ordering Support eBooks Covers Sandbox Forums Distributors Manning Early Access Program (MEAP) Press Academic User Group Program Jobs Search manning.com Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 PowerBuilder 6.0 Questions & Answers Tim Hatton 1998 | 446 pages ISBN: 1884777708 Out of Print $43.95 Softbound print book RESOURCES Index Table of Contents DESCRIPTION Revised printing for PowerBuilder 6.0 Includes new PFC chapter by Richard Brooks Demand for PowerBuilder programmers, with the potential they offer for rapid application development, continues to soar. If you'd like to learn PowerBuilder--or enhance your skills-- this book is for you. Its hands-on approach will show you how to write real code. Each section takes a specific "How do I?" topic and answers commonly asked questions in an easy-to-understand, conversational manner. It then shows you how the same technique can be used over and over again to decrease your overall code-writing time. What's inside: How to install the development environment to meet your needs Making your applications object efficient Using libraries effectively while protecting your code Manipulating Datawindows Building distributed applications Using PowerBuilder on the Internet Extensive chapter on PFC WHAT THE EXPERTS SAY ABOUT THIS BOOK "I would especially recommend this book to someone who is attempting to learn PowerBuilder by themselves, either at home or on a one-person project." --Steven Katz, PowerBuilder Object Library Architect "I absolutely recommend this book.The Q∓A format is unique and directly addresses critical questions often asked by the novice." --Cary Hakes, Senior Developer "...his conversational style of communicating works very well. It's as though we were sitting room talking." --Dave Brown, President, The Mulligan Group "The author's use of tables, examples and illustrations is excellent. For example, his explanation on variables is very good because he supports his answers with a common situation." --Lola Adegoke, IT Consultant ABOUT THE AUTHOR Tim Hatton is a sought-after consultant and experienced client-server developer. He is a PowerBuilder specialist and teacher and has written two other books for Manning Publications: The Awesome Power of PowerJ and The Awesome Power of Power++. Sample Chapters Two sample chapters are available for download. Chapter 2 Chapter 3 Introduction Introduction to the revised printing Now that PowerBuilder 6.0 is a released product, it's time to update this book with questions and answers related exclusively to PowerBuilder 6.0. Questions from the previous edition have been updated to reflect the changes made by PowerBuilder 6.0, but with the understanding that not everyone will switch, I have, where possible, left the old answers in place. PowerBuilder 6.0 makes many changes to the development environment. These changes are grouped by PowerSoft into four broad categories: Developer productivity PowerBuilder has included tools that allow you to write more code better and faster than ever. Wired for the Web PowerSoft continues to support immediate, high-productivity development of middle-tier application logic and its accessibility from web-based clients. Component easy PowerBuilder will enable RAD development of applications comprising standard components in distributed architectures. Open technology PowerBuilder will allow flexible and easy deployment in a rapidly changing enterprise environment. Developer productivity and other enhancements Many of you probably have not yet converted PowerBuilder 4.0 (or even 3.0) apps into PowerBuilder 5.0 versions. Now, with this new version, you have to wonder whether upgrading is worth the effort. It is, if for no other reason than to get your hands on the new debugger. In the previous edition, I complained about the debugger not supporting some of the features you would expect from a modern development environment. PowerSoft must have listened because the debugger has undergone a major facelift. Now, we can set conditional breakpoints and view the call stack and objects in memory. The debugger will support viewing panes of information (up to nine) which can be overlapped to form tabbed views. You will be able to break into the debugger at runtime too. You also get enhanced application profiling and tracing options to allow you to collect, trace, and analyze information about the execution of your application. The ability to display the collected information will be available. Even if nothing else were new, the enhanced debugger would make it worth the upgrade. But we get more. The toolbars have been revamped to use the Windows 97 style popularized by Microsoft Internet Explorer 3.0. And we have new toolbar items that invoke the options to generate Windows Registry entries and open the Synchronization Tool. The DataWindow, the reason for PowerBuilder's popularity over the years, has been enhanced. Now we can put buttons on DataWindows and group data using group boxes, so we don't have to use superimposed rectangles to give a 3D effect. There are additional formats available for saving data. Overcoming one of the worst deficiencies in PowerBuilder 5.0's version of Distributed PowerBuilder, we can now share data between client-side and server-side DataStores. This will make the passing of data and changes to data between client and server much easier, and will ease the move into three (or more) tiered client/server computing. For all these reasons, PowerBuilder 6.0 is worth a look. Wired for the Web The programming world has changed since the release of the first version of PowerBuilder, and the rate of change has increased since the release of version 5.0. PowerSoft responded to the mass move to the Internet by releasing interim tools that allowed developers to leverage their PowerBuilder coding skills and even their existing code bases. Now, PowerSoft expands that effort with PowerBuilder 6.0 and its "wired to the Web" approach. PowerBuilder 6.0 adds the following Internet/intranet development features: Integration of the Internet Developer Toolkit into PBEAll components previously released as the IDT are included with PowerBuilder Enterprise: Web.PB DLL Web.PB class library For generating HTML and managing the state of a browser connection Web.PB wizard To create the HTML elements required to invoke the services of distributed objects PowerBuilder Window Plug-in DLL Standard and secure mode versions PowerBuilder DataWindow Plug-in DLL Standard version only O'Reilly WebSite Web server software Restructuring of the PowerBuilder deployment DLLs into the PowerBuilder VM Many of the PowerBuilder deployment DLLs have been combined to ease deployment of the PowerBuilder runtime environment which has been renamed PowerBuilder VM. The new PowerBuilder VM consists of two common DLLs (approximately 5MB) and any specific database driver DLLs needed by the application. This is a significant improvement over the number of DLLs required to distribute applications written in previous versions of PowerBuilder. Synchronization tool This additional application verifies that the local copy of the PowerBuilder VM includes the latest versions of all DLLs, and, if not, it will automatically update the DLLs as needed. Developers will be able to set up SynchWin to run automatically at either machine or application startup time. SynchWin will be available as both 16- and 32-bit Windows executables (no Macintosh or UNIX support) and as an ActiveX. Secure mode Window Plug-in/ActiveX Secure mode provides alternative DLLs for the PowerBuilder Window Plug-in and ActiveX. The secure version prevents the Plug-in/ActiveX from making any changes to the user's machine. This addresses many of the industry's concerns about ActiveX security. Code signing for Plug-In/ActiveX Microsoft code signing verifies that downloaded code is coming from the selected source, and that the code hasn't been changed during download. Context Object The Context Object is a global object available to an ActiveX or Plug-in that provides access to information and services available to the ActiveX or Plug-in component. It exposes browser services to the PowerBuilder programmer, such as allowing posts and gets or making HTTP requests. SaveAs HTML enhancements The Save As HTML form adds the capability to generate HTML form syntax. In the case of free form or tabular DataWindows, HTML form syntax can be generated for a row or range of rows, and for all columns or a range of columns. Columns that have a nonzero tab order become input fields, and names for the HTML form INPUT fields are derived from the column names. Text, computed columns, and so forth become text. Buttons become buttons. Other mappings from PB controls are made as appropriate (radio buttons, check boxes, list boxes, etc.) All input fields are wrapped in HTML table syntax using the same heuristics for placement as SaveAs(HTMLTable!) to ensure reasonable field placement. Embedded nested DataWindows will be stored as HTML tables in the generated HTML syntax. DataWindow HTML generation will better preserve the DataWindow presentation, making it more flexible and easier to generate dynamic web pages. Web.PB shopping carts Shopping cart applications allow Web.PB to accept multiple values under the same argument name. This will allow selection of multiple items so that shopping cart-type applications can be supported. Window ActiveX The Window ActiveX is an ActiveX wrapper that can hold PowerBuilder windows. It functions similarly to the Window Plug-in, but has methods associated with it. The Window ActiveX can be embedded into any application that supports ActiveX, but requires the PowerBuilder VM. The Window ActiveX will be provided in both standard and secure mode versions. All these new features demonstrate PowerSoft's intention to allow you to leverage existing PowerBuilder skills while moving to Internet/intranet programming. Component Easy PowerBuilder 6.0 fully supports the move toward distributed, component-based application architectures. This move is being driven by the increasing demands for application scalability, code reusability, flexibility, and maintainability. Collectively, PowerSoft calls the enhanced features available in PowerBuilder 6.0 Component Easy. They are: Object generator infrastructure PowerBuilder 6.0 includes architectural infrastructure into which component generators can be inserted. Plans are to add code generators to support the creation of C++, CORBA, DCOM, and other standard object types, from PowerBuilder developed objects. Jaguar component transaction server support PowerBook objects, wrapped as OLE servers, will be supported by Jaguar CTS from Sybase. Basic support for Microsoft transaction server PowerBuilder 6.0 can act as a consumer of MTS objects, or as a server on an MTS server (OLE automation object). However, no transaction support is currently available. Asynchronous application server processing Asynchronous processing provides a mechanism to queue client requests on an application server for processing, and allows the client call to return prior to completion of the call to the application server. It also allows server execution to continue outside the scope of a specific client call. Server push Server push allows distributed PowerBuilder application servers to send out-of-band messages to application clients. Server push can be used to send results from asynchronous method calls back to clients, or as a general method of signaling from server to client. Name Server utility The Name Server utility provides a logical redirection mechanism between a logical server name and a physical application server. The Name Server utility can also be used to balance client connection loads among like servers and to provide connection information for distributed PowerBuilder application servers. Application server shared objects The shared objects feature allows multiple client sessions running on one application server to share objects instantiated on that server. Named instances of objects can be registered as shared objects with the main server application. Once registered, shared objects can be accessed by any client session running in the main application server session. (Shared objects are not accessible to objects executing outside of the server session, such as end user clients.) Requests on shared objects are queued sequentially to reduce concurrency issues. A shared object instance is deleted automatically when the server shuts down, or programmatically when its names instance is deregistered or when explicitly deleted using a DELETE statement. Secure socket layer support A new distributed PowerBuilder driver for the Secure Socket Layer provides increased security when using distributed PowerBuilder. Window ActiveX The Window ActiveX is an ActiveX wrapper that can hold PowerBuilder windows. It functions similarly to the Window Plug-in, but has methods associated with it. The Window ActiveX can be embedded into any application that supports ActiveX, but requires the PowerBuilder VM. The Window ActiveX will be provided in both standard and secure mode versions. Add these to the features discussed above and you can easily see that PowerBuilder will maintain its market dominance even in a world moving to component-based and distributed computing technologies. Open technology PowerBuilder 6.0 continues to demonstrate PowerSoft's commitment to openness, and includes support for additional platforms, new database interfaces, foreign languages, and emerging transaction server technologies. Among these are: Extended UNIX platform support Extending UNIX platforms support to include IBM AIX and HP UX variations expands development and deployment options for PowerBuilder developers. Open support for component model standards PowerBuilder 6.0 supports future creation of multiple standard components, including ActiveX and CORBA components and JAVA Beans. Open transaction server support PowerBuilder acts as both a consumer and producer of objects for multiple transaction servers, including Sybase's Jaguar CTS and the Microsoft Transaction Server. Expanded database connectivity PowerBuilder 6.0 adds support for native connectivity to Informix 7.2 (32-bit Windows platforms only). New support for Sybase SQL 11.1 includes added support for OpenClient 11.1 security and directory services, and provides enhanced UNIX and Macintosh performance. ODBC 3.0 support is also provided. PowerBuilder 6.0 includes appropriate versions of SQL Anywhere in all platform versions (including UNIX). Expanded language support PowerBuilder 6.0 is available in several new language versions, significantly expanding its language support. It is available in 32-bit Arabic and 32-bit Hebrew right-to-left language versions. A new Unicode version of PowerBuilder Enterprise is available for the Windows NT 4.x platform. The PowerBuilder Unicode version has been implemented to support Unicode (which always uses a full two bytes to store any character), as opposed to UTF8 (which uses a variable number of bytes to store different characters). All dialogs and built-in displays are presented in English. Applications built using the Unicode version of PowerBuilder must be deployed on machines that have the PowerBuilder Unicode deployment DLLs running under an operating system that supports Unicode versions as long as all characters used are supported by ANSII. PowerBuilder translation tools, formerly known as the PowerBuilder Translation Toolkit, are no longer sold separately but are bundled with and available for use only with PowerBuilder Enterprise. Expanded support for third-party application interfaces Class definition enhancements in PowerBuilder 6.0 enable users to obtain information about PowerBuilder class definitions via Powerscript. PowerBuilder supplies a set of user object classes that provide information about PowerBuilder object classes and their contents. All properties are read only. PowerBuilder 6.0 implements a new source code control (SCC) interface which complies with the Microsoft common SCC interface specification. Proprietary source code control interfaces supported with earlier version of PowerBuilder remain accessible to third party vendors, but will not be enhanced. PowerBuilder 6.0 includes an OLE interface to the existing testing tools interface to simplify and standardize access. PowerBuilder 6.0 supports saving DataWindows to Excel 5 format and to ASCII. The ASCII save option also includes saving computed columns and headings, rather than column names. Expanded device support PowerBuilder 6.0 supports use of the IntelliMouse pointing device. IntelliMouse users will be able to use special device features to enhance DataWindow scrolling, and navigation through list, and tree views. These features demonstrate PowerSoft's commitment to making PowerBuilder work on all major platforms and against all major RDBMS. The combined feature list of PowerBuilder 6.0 shows that we are moving toward the next generation of client/server computing, and that the major player in the game will be the one that redefined client/server programming to begin with: PowerSoft. You cannot go wrong by learning this tool. The PowerSoft Foundation Classes This edition also includes a chapter, written by Rik Brooks, answering questions about the PowerSoft Foundation Classes. Like them or not, many corporations are adopting the PFC as their basic application framework. And those who develop their own framework are using techniques learned from an examination of the PFC code. Thanks to Rik for stepping in to write that chapter. In addition, purchase of the PowerBuilder Questions and Answers book includes free access to a private Internet forum. See Author online at the back of this book for details. All source code for the examples presented in PowerBuilder Questions and Answers is available to purchasers from the Manning web site. The URL http://www.manning.com/hattonincludes a link to the source code files. Introduction The PowerBuilder phenomenon Little did I realize in the fall of 1993 when I answered a posting on CompuServe for a Visual Basic programmer, that I was about to embark on an incredible adventure into the world of client/server programming with PowerBuilder. After being hired to write a Visual Basic application for a small company, I was surprised when, on my first day, I was handed a copy of PowerBuilder and informed that the project was to be done in a language about which I knew absolutely nothing. PowerBuilder was in its 2.0 release and version 3.0 was in late beta. Visual Basic and C/C++ ruled the Windows programming market and most of my experience up to that point had been in those languages, with a little xBase thrown in for good measure. When I took my first look at the beta version of PowerBuilder 3.0, I hated it. I was pretty much alone in that regard. PowerBuilder 3.0 took the market by storm in 1993. Almost every major programming shop immediately began converting applications and PowerBuilder programmers were in great demand, a trend that continues to this day. PowerBuilder programmers are on the high end of the salary scale and they have a great deal of job security as well. Now in version 5.0, the PowerBuilder phenomenon shows no sign of abating. The help-wanted ads for computer programmers have the word PowerBuilder as a permanent fixture. The Internet newsgroups are filled with requests for PowerBuilder developers, and a posted resume and notice of availability will bring dozens of responses. And as company after company continue the process of reengineering, PowerBuilder remains the tool of choice. There has been speculation that the rise of the Internet would sound the death knell for PowerBuilder's brand of client/server computing. This has not been the case. Instead, companies are looking for ways to leverage their existing code into Web-enabled applications. PowerSoft has stepped into the breach here, and is providing new methods for developers to move their code to the Internet. These include the DataWindow Plug-in--which allows the generation of a DataWindow report which can be displayed on any HTML page, and the Window Plug-in--which allows the placement of a fully operational child window inside an HTML page. These innovations show that PowerSoft is committed to moving their mainstream products into the Internet arena and providing additional incentive for learning to code in PowerBuilder. Who should read this book? This book is for the beginning to intermediate PowerBuilder developer: one just starting out or one who wants to add bells and whistles to a project that is under way. It is de-signed to be a good reference that explains in nice, neat terms exactly how to do something and why it should be done that way. The questions in this book were compiled from the Internet and the PowerBuilder Forum on CompuServe and from many other sources, including personal experience as a member of a development team. The material for this book was written using the released version of PowerBuilder, not the beta version. The questions and answers are divided by subject areas that are well known to PowerBuilder developers and each question is preceded by a summary of its contents. Where it is helpful, I have included sample code and related tips and tricks. When a question deals with a PowerBuilder bug (oops, I mean feature) I have included workaround solutions. In all, the book is intended to be a reference to use as needed and not one which you will read once and put on a shelf to gather dust. But this book is more than just a question-and-answer session. In almost every section, as part of the answer, I have attempted to explain why things work the way they do in both PowerBuilder and Windows. You may consider this book to be a general course in how to program in PowerBuilder. Object-oriented programming PowerBuilder is an object-oriented programming language and I am a big believer in using object-oriented techniques where they save time and code. What follows is a very generalized overview of object-oriented programming. In order to be considered object-oriented, a language must support three features: encapsulation, inheritance and polymorphism. Encapsulation The ability to enclose all of the code that makes an object work inside the object itself. An object should be a "black-box" to the end user (and that includes programmers). You need not know how the object works in order to use it; you need only know those properties and methods that the object exposes to you. Think of your car as an object. Your car has an engine property. It has a start method. You do not need to know how the start method actually starts the engine property; you only need to know how to call the start method. Now think of a command button. It has a text property (what the button label says). You don't need to know how the button draws the text, you only need to know how to set it. All the code that makes the button be a button is encapsulated in the button. Now, using the command button example again, what if, in order to change the text of the button, you had to call a global function f_setbuttontext and pass it the button name and the text value? This would break encapsulation because some of the code that makes the button work would now be outside the button. Simple concept, sometimes difficult to do completely. Inheritance The ability to create a subclass (the descendant) of a type of object (the ancestor) and have the descendant have access to all the exposed properties and methods of the ancestor, with the ability to add properties and methods to the descendant that are not present in the ancestor. Think of the command button. It has a SetFocus() method. If you inherit from the command button, you will get a command button that also has a SetFocus() method (actually the ancestor's). You can then add a method called MoveButton() that moves the button's location on the window. The ancestor command button could not call the MoveButton() method, but the descendant can call both the SetFocus() and MoveButton() methods. A more difficult concept; difficult to use properly. Polymorphism The ability to change an object to make it perform another task. Most objects are not polymorphic. They don't have to be. The biggest use of polymorphism is in functions. What is new in PowerBuilder 5 is the ability to have two functions with the same name that take different parameters. You can have a function such as f_addtwovariables(int1, int2) and f_addtwovariables(string1, string2). When you call f_addtwovariables(1, 2) , the function returns 3. When you call f_addtwovariables("A","B"), the function returns AB. The usefulness is that the programmer only needs to know one function to call when he needs to add any two variables. This is sometimes referred to as overloading. Some consider the ability to change an object's properties to be polymorphism. I think that it isn't polymorphic merely to allow properties to be altered. For example, the DataWindow control has a dataobject property. As you will learn, changing the dataobject will change what is displayed in the control. But it is still the same object and it is still the same control; all you have done is permissibly alter the dataobject property of the control. As I said, this is a very generalized overview of object-oriented programming. Specific details are spread throughout this book and if you keep this overview in mind while reading those sections you will be better able to understand them. My approach to object-orientedness stresses encapsulation over the other two and deemphasizes polymorphism. Where to start Those who are new to client/server programming should start with the overview in chapter 1 which covers the topic in general terms and explains what PowerBuilder is and where it fits into the scheme of things. If you know about client/server programming and PowerBuilder but have not yet installed it (or if you are having an installation problem or a question about installation), you should start with chapter 2, which covers common installation questions and problems. If PowerBuilder is working on your machine and you need to learn how to use it, then you should start with chapter 3, which gives an overview of the PowerBuilder Application Object and serves as a good starting point for the discussion in this book. And, if you are a more advanced developer, you can pick and choose your chapters and sections depending on what you want to learn today. Preview of coming attractions Just as this book was prepared to go to press, PowerSoft did what all software companies do--they announced a new version, thus proving the old adage that the more things change, well, the more they change. Since we had a little time to deal with this, the publisher and I agreed to include a preview of some features that will be new to PowerBuilder 6.0 (was released in the third quarter of 1997). This chapter can be used to plan your update schedule and to give you ammunition when you want to use PowerBuilder 6.0 for development and your project managers want to stay with the tried and true older versions. The features list for PowerBuilder 6.0 goes well beyond that which has been included in all of the earlier versions. If you are doing Internet/intranet programming, upgrading will be a no-brainer. The same goes for Distributed Computing. If there is any PowerBuilder programmer who is losing sleep wondering if his skills will be in demand as the world moves to Internet/intranet, Distributed Computing, and component-based architectures, read the Introduction on PowerBuilder 6.0 and then get a good night's sleep. But, if I tell all in the introduction, why read the book?