Context information service

You use the context information service to obtain information about an application’s execution context. The service provides current version information, as well as whether the application is running in the PowerBuilder execution environment.

Accessing context information

Using the context information service, you can access the information in Table 21-4.

Table 21-4: Context information

Item

Use this function

Comment

Full context name

GetName

Value returned depends on the context:

  • Default: PowerBuilder Runtime

Abbreviated context name

GetShortName

Value returned depends on the context:

  • Default: PBRUN

Company name

GetCompanyName

Returns Sybase, Inc.

Version

GetVersionName

Returns the full version number (for example, 12.5.0.1)

Major version

GetMajorVersion

Returns the major version number (for example, 12.5)

Minor version

GetMinorVersion

Returns the minor version number (for example, 0)

Fix version

GetFixesVersion

Returns the fix version number (for example, 1)

NoteUsing the ClassName function for context information You can also use the ClassName function to determine the context of the object.

You can use this information to verify that the context supports the current version. For example, if your application requires features or fixes from Version 12.5.0.1, you can use the context information service to check the version in the current execution context.

StepsTo access context information:

  1. Declare an instance or global variable of type ContextInformation:

    ContextInformation icxinfo_base
    
  2. Create the context information service by calling the GetContextService function:

    this.GetContextService("ContextInformation", &
    
       icxinfo_base)
    
  3. Call context information service functions as necessary.

    This example calls the GetShortName function to determine the current context and the GetVersionName function to determine the current version:

    String  ls_name
    
    String  ls_version
    
    Constant String ls_currver = "12.5.0.1"
    
    icxinfo_base.GetShortName(ls_name)
    
    IF ls_name <> "PBRun" THEN
    
       cb_close.visible = FALSE
    
    END IF
    
    icxinfo_base.GetVersionName(ls_version)
    
    IF ls_version <> ls_currver THEN
    
       MessageBox("Error",  &
    
          "Must be at Version " + ls_currver)
    
    END IF