| By Todd Jones | Article Rating: |
|
| July 1, 2001 05:00 PM EDT | Reads: |
8,621 |
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,621
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.
- SQL Anywhere Server and AJAX
- PowerBuilder Top Feature Picks
- The Difference Between Web Hosting and Cloud Computing
- PowerBuilder 12 and .NET
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Migrating Legacy Client/Server PowerBuilder Apps
- Why SOA Needs Cloud Computing - Part 1
- PowerDesigner 15: Expanding Data Modeling into Your Enterprise
- Five Reasons to Choose a Private Cloud
- PowerBuilder and .NET: Development Strategy
- SQL Anywhere Server and AJAX
- PowerBuilder Top Feature Picks
- The Difference Between Web Hosting and Cloud Computing
- PowerBuilder 12 and .NET
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- SYS-CON's iPhone Developer Summit Day One ROCKS
- A Review of Key PDF and Font Concepts
- Migrating Legacy Client/Server PowerBuilder Apps
- New Features in PowerBuilder 11.5
- New Features in PowerBuilder 11.5
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- 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


































