Context information

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 PowerBuilder Browser.

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.

StepsTo enable a service:

  1. Establish an instance variable of the appropriate type:

    ContextInformation icxinfo_base
    
    ContextKeyword     icxk_base
    
    CORBACurrent       corbcurr_base
    
    ErrorLogging       erl_base
    
    Inet               iinet_base
    
    SSLServiceProvider sslsp_base
    
    TransactionServer  ts_base
    
  2. Instantiate the instance variable by calling the GetContextService function:

    this.GetContextService("ContextInformation",  &
       icxinfo_base)
    
    this.GetContextService("ContextKeyword", icxk_base)
    // Use Keyword instead of ContextKeyword on EAServer
    
    this.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.