| By Todd Jones | Article Rating: |
|
| July 1, 2001 05:00 PM EDT | Reads: |
8,700 |
The latest PowerBuilder productivity enhancements will make our jobs as developers easier and reduce development time. Among the many improvements in PowerBuilder 8 are the additions to PowerScript of four printer functions that support changing the default printer and its document properties. These functions, printGetPrinter, printGetPrinters, printSetPrinter, and printSetupPrinter, implement library routines that, in previous versions of PowerBuilder, would have required external function calls or the use of third-party products.
Let's begin this discussion with the two getter functions, printGetPrinter and printGetPrinters. Both return tab-delimited strings containing the printer, driver, and port names, allowing each to be easily loaded into a DataWindow using the importString method (see Listing 1). The difference between these functions is that printGetPrinter returns only the default printer (or the printer that's set as current with printSetPrinter), while printGetPrinters returns a list of all printers available to the system. It should be noted that printGetPrinter won't return the default printer if that printer was changed to default outside of the application.
Complementing the getter functions is the setter function printSetPrinter. This function sets the printer you'll be using for the next print task. printSetPrinter is called with a single string parameter, printer_name (see Listing 2), and won't affect currently open print jobs. The printer_name argument must be a valid printer name as returned by the printGetPrinters function.
The last function to discuss, printSetupPrinter, simply displays the printer's document properties dialog box provided by the system print driver, allowing users to specify document settings for the current printer (see Figure 1). The current printer can't be changed with this function (as is possible with the printSetup function).
To demonstrate these new functions I've included a small sample application consisting of one window and two DataWindows (one dropdown DataWindow). The application displays a list of available printers with associated driver and port names (printGetPrinters) defaulting to the current printer (printGetPrinter). Once the user chooses another printer from the dropdown DataWindow, that printer is made current (printSetPrinter). At any time the user may click the "Properties" button to display the printer's document properties dialog box (see Figure 1) for the currently selected printer (printSetupPrinter).
Sybase's work with the PowerBuilder development community has produced many new enhancements in PowerBuilder 8 that can make any developer's life easier. When you have the chance, peruse the "What's New" section of the help file. I'm sure you'll find many improvements, including the functions discussed here, that you can immediately use in your code.
Published July 1, 2001 Reads 8,700
Copyright © 2001 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Todd Jones
Todd Jones is a senior consultant with Sybase Professional Services in Denver, Colorado. He has over 11 years of experience in the IT industry and is certified as a PowerBuilder Developer Associate and a Sybase Server Administrator Associate.
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Names The World's 30 Most Influential Virtualization Bloggers
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects

































