Title: PWB517 PBNI::Introduction by Example
1PWB517 PBNIIntroduction by Example
Roy KieslerTeam Sybaseroy.kiesler_at_teamsybase.com
2PBNIIntroduction by Example
Introductions
- Roy Kiesler
- Architect, Percussion Software, Professional
Services. - Specialize in XML and Java content management
systems. - Background C, PowerBuilder
- Member of Team Sybase since 1999
- Winner of the 2001, 2003 Team Sybase MVP ward
- Audience
- PowerBuilder developers
- C developers
- .NET developers
- Sybase Tools Seminar 2003 attendees (Minneapolis,
MN)
3What is PBNI?
Whats in a Name?
- PowerBuilder Native Interface
- PowerScript
- PBNI is a standard programming interface that
allows developers to extend PowerScript with C
classes - This feature is targeted at Client/Server
applications, as well as rich distributed clients - PBVM Anywhere
- PBNI also enables one to embed the PowerBuilder
VM in C applications and either run complete
PowerBuilder applications or invoke selective
PowerScript functions - This feature provides the ability to deploy
PowerBuilder custom class user objects to
third-party application servers
4What is PBNI?
Seeing is Believing
- Code Examples
- Power Pack
- Fast array sorting
- Base64 encoding/decoding
- Bitwise operations
- CPU information
- ASA DBTools API
- Network operations
- Visual Controls
- Custom-drawn List and Tree View controls
- Owner-drawn command buttons
- More
- Callbacks
- XPath
5What is PBNI?
Seeing is Believing
- Did you know?
- Sybase is eating its own dog food with
PowerBuilder 9.0 - Web Services SOAP Client
- EJB Client
- PBDOM
- All are PBNI implementations!
6PBNIIntroduction by Example
PBNI Core Interfaces
- PBNI exposes 4 core C interfaces
-
PBVM -
Anywhere - PowerScript
- IPB_Session
- IPB_Value
- IPB_Arguments
7PBNI-gtPowerScript
Core Interfaces
- IPB_Session
- An abstract interface that provides a low-level
interface to PowerScript - Defines functions for
- Accessing PowerScript data
- Calling PowerScript functions
- Catching and throwing PowerScript exceptions
- Setting a marshaler to convert PowerBuilder data
formats to the users communication protocol. - IPB_Value
- An abstract interface that provides a high-level
interface to PowerScript - Allows for better data integrity
- Provides some protection from coding many
operations that could cause crashes (e.g.,
assigning a long value to a string variable)
8PBNI-gtPowerScript
Core Interfaces
- IPB_VM
- An abstract interface that enables 3rd party
client and server applications to load the
PowerBuilder VM and run a PowerBuilder
application/component - IPB_Arguments
- An interface that encapsulates the functionality
of passing values between the PowerBuilder VM and
a PBX. - Arguments are passed as pointer to an instance of
the IPB_Value interface.
9PBNI Core Interfaces
The Big Picture
10PBNI-gtPowerScript
Class Hierarchy
- PBNI classes can inherit from
- NonVisualObjet and its descendants, e.g.
- Connection
- Error
- Exception
- Transaction
- UserObject and its descendants
- PBNI extensions (PBXs) can expose
- Object-level functions and events
- Global functions
11PBNIIntroduction by Example
PBNI-gtPowerScript
- Advantages
- Performance
- True machine-code execution
- Convenience
- Ability to return strings and arrays instead of
passing by REF - No need to pre-allocate memory using Space(n)
- No need to declare complex structures
- Auto-generated PBD just add to your library
list and code
12PBNIIntroduction by Example
PBNI-gtPowerScript
- Limitations
- Complexity
- Solid C knowledge required, as PBNI uses
advanced C concepts like templates and traits - Functionality
- Properties can only be exposed via Get/Set
methods, which, while common in C/Java, are
less prevalent in PowerScript (uses instance
variables) - Debugging
- C debugger required
13PBNIIntroduction by Example
PBNI-gtPowerScript
- Required exported functions
- PBX_GetDescription
- Returns a string with PowerScript-like export
syntax of all PBXs methods and events and any
global functions. Used by the PBX2PBD90 tool. - PBX_CreateNonVisualObject
- Invoked in response to a PowerScript CREATE
statement - PBX_CreateVisualObject
- Invoked when a new visual PBX is instantiated
- PBX_InvokeGlobalFunction
- Invoked when a global PBX function is called
14PBNIIntroduction by Example
PBNI-gtDevelopment
- Setting up a development environment
- C IDEs/Compilers
- Visual C 6.0
- Visual C .NET 2003
- Borland C Builder
- GNU gcc
- Include Directory (INCLUDE)
- C\Sybase\PowerBuilder 9.0\SDK\PBNI\include
- Library Directory (LIB)
- C\Sybase\PowerBuilder 9.0\SDK\PBNI\lib
15PBNIIntroduction by Example
PBNI-gtDevelopment
- Header Files
- pbext.h contains structures and interfaces used
to implement PBXs - pbni.h contains structures and interface
definitions for core PBNI - pbnimd.h contains machine-dependent (Win32) type
definitions - pbarray.h contains template classes for creating
and accessing arrays - pbfield.h contains template classes for creating
and accessing class variables - pbtraits.h contains template structures used in
pbarray.h and pbfield.h - Library Files
- pbni.lib
- Every PBNI class should include ltpbext.hgt
- You should not include any other PBNI header
file in your class
16PBNIIntroduction by Example
PBNI-gtDevelopment Quick Start
- Visual C 6.0 AppWizard
- C\Sybase\PowerBuilder 9.0\SDK\PBNI\wizards\pbext.
awx
17PBNIIntroduction by Example
PBNI-gtDevelopment Quick Start
- Visual C .NET AppWizard
- http//codexchange.sybase.com
18PBNIIntroduction by Example
PBNI-gtToday
- PBNI implementations available today
- XML/XSLT API
- PBDOM, XPath evaluator
- Java interoperability
- PB2Java, EJB client, PDF encryption
- .NET interoperability
- PDF encryption
- Web Services
- SOAP client
- Complex API wrappers
- Callback functions (DBTools, Win32 enumerations)
19PBNIIntroduction by Example
PBNI-gtToday
- PBNI implementations available today
- PB-friendly COM wrappers
- Event support
- Visual objects
- Sub-classing
- Custom/owner-drawn controls
- Utility classes
- Bitwise operations
- SMTP
- Base64
- STL collection classes (map, list, queue, stack)
- CPU Information
20PBNIIntroduction by Example
PBNI-gtCode Examples
- Code Walkthrough
- PBNI Power Pack
- .NET (Managed C)
- Callbacks
- Visual Controls
- XPath Evaluator
- More (time permitting)
21PBNIIntroduction by Example
PBNI-gtTomorrow
- PBNI implementations to look for
- PBSAX XML Parser
- NT Services
- Windows Hooks
22PBNIIntroduction by Example
PBNI-gtQuestions
23TeamSybase Shameless Plug
Dont Judge a Book by Its Cover
- Advanced Client/Server Internet Distributed
Development
24SDN Presents CodeXchange
A New Benefit for Sybase Developers
- Forum for exchanging samples, tools, scripts,
etc. - New features enable community collaboration
- Download samples created by Sybase or external
users - Leverage contributions of others to extend Sybase
products - Contribute code or start your own collaborative /
open source project with input from other product
experts - Any SDN member can participate
- Log in using your MySybase account via SDN
- http//codexchange.sybase.com
- Or via SDN at www.sybase.com/developer
- SDN CodeXchange at TechWave
- Visit SDN in the Technology Boardwalk
- Learn about CodeXchange in the Sybase Booth
Theater