Use the context keyword service to access environment information for the current context. In the default environment, this service returns host workstation environment variables. In the PowerBuilder window plug-in, this service allows you to access parameters specified in the plug-in’s Embed element. When running within EAServer, you can use the keyword service to get component property values.
For information about using the context keyword service in EAServer, see “Accessing component properties”.
When running in the PowerBuilder execution environment (the default context), you use this service to return environment variables.
To access environment variables:
Declare an instance or global variable of type ContextKeyword. Also declare an unbounded array of type String to contain returned values:
ContextKeyword icxk_base
String is_values[]
Create the context information service by calling the GetContextService function:
this.GetContextService("ContextKeyword", icxk_base)
Call the GetContextKeywords function to access the environment variable you want. This example calls the GetContextKeywords function to determine the current application Path:
icxk_base.GetContextKeywords("Path", is_values)
Extract values from the returned array as necessary. When accessing environment variables, the array should always have a single element:
MessageBox("Path", "Path is: " + is_values[1])
The Embed element can contain additional, user-specified, parameters. Additionally, the Embed element allows more than one value for each parameter.
When running in the PowerBuilder window plug-in context, you use this service to access parameters specified in the Embed element. If the specified parameter is not found, the service tries to match the specified parameter with an environment variable.
To access Embed element parameters:
Declare an instance or global variable of type ContextKeyword. Also declare an unbounded array of type String to contain returned values:
ContextKeyword icxk_base
String is_values[ ]
Create the context information service by calling the GetContextService function:
GetContextService("ContextKeyword", icxk_base)
Call the GetContextKeywords function. This example calls the GetContextKeywords function to access values for the user-specified parameter, VALID:
icxk_base.GetContextKeywords("VALID", is_values)
Extract values from the returned array as necessary. This example displays parameters in a list:
Integer li_count
FOR li_count = 1 to UpperBound(is_values)
lb_parms.AddItem(is_values[li_count])
NEXT