Context information
Contents
The PowerBuilder context feature allows applications to access
certain host (non-PowerBuilder) services. This is a PowerBuilder
implementation of functionality similar to the COM QueryInterface.
PowerBuilder provides access to the following host services:
PowerBuilder creates service objects appropriate for the current
execution context (native PowerBuilder or transaction server). This allows
your application to take full advantage of the execution
environment.
The context feature uses seven PowerBuilder service objects:
ContextInformation, ContextKeyword, CORBACurrent, ErrorLogging, Inet,
SSLServiceProvider, and TransactionServer; it also uses the InternetResult
object. (The context feature is sometimes called the Context object, but
it is not a PowerBuilder system object.)
For more information about these objects, see Objects and Controls or the section called “Browsing the class hierarchy” in Users Guide.
Enabling a service
Before you use a service, you instantiate it by calling the
GetContextService function. When you call this function, PowerBuilder
returns a reference to the instantiated service. Use this reference in dot
notation when calling the service’s functions.
To enable a service:
-
Establish an instance variable of the appropriate type:
1234567ContextInformation icxinfo_baseContextKeyword icxk_baseCORBACurrent corbcurr_baseErrorLogging erl_baseInet iinet_baseSSLServiceProvider sslsp_baseTransactionServer ts_base -
Instantiate the instance variable by calling the
GetContextService function:123456789101112this.GetContextService("ContextInformation", &icxinfo_base)this.GetContextService("ContextKeyword", icxk_base)// Use Keyword instead of ContextKeywordthis.GetContextService("Keyword", icxk_base)this.GetContextService("CORBACurrent", &corbcurr_base)this.GetContextService("ErrorLogging", erl_base)this.GetContextService("Internet", iinet_base)this.GetContextService("SSLServiceProvider", &sslsp_base)this.GetContextService("TransactionServer",ts_base)
Using a CREATE statement
You can instantiate a service object with a PowerScript
CREATE statement. However, this always creates an object for the default
context (native PowerBuilder execution environment), regardless of where
the application is running.