BaseContext :: parameter - Retrieving parameters
Typically, parameters for context actions are passed in a parameter string as comma separated parameter values by calling setParameter() before calling executeFunction(). The function analyzes the parameter string and selects parameters by keyword or position. The first parameter has position 1.
The function is called from within a user context function in order to retrieve parameters passed by the user function.
Parameters can be retrieved by position or key name, when the parameter string contains keyword parameters.
When the context handle does not refer to a valid context instance the function throws an exception.
The parameter() function returns the parameter value in a work area. This will be destroyed, when retrieving the next parameter. Hence, function calls like Funct( parameter(1),parameter(2) ) will not work properly. The result from at least one of the parameter() calls must be moved to a local variable.
Parameters are reset automatically, when the action had terminated. In case of calling context functions recursively, i.e. when another context action is activated from within an action, parameters become invalid. Hence, parameters should be read at the beginning of a context action, always.
Implementation overview
- Get parameter by key word
BaseContext :: parameter ( sParameterKeyword ) - Get parameter value at position
BaseContext :: parameter ( iParameterCount )
Implementation details
-
Get parameter by key word
odaba::String BaseContext  :: parameter ( odaba::String &sParameterKeyword )
Keyword parameters can be defined in three ways in the parameter string:
- name=value;
- name:value
- name(value)
Passing the keyword name, the function will return the value from the parameter string, when being defined. Otherwise, the function returns an empty string.
// parm string passed: "last:otto,first(paul),place=village"
parm("first"): "paul"
parm("place"): "name=village"
parm("last") : "otto"
parm("nonsense"): ""
- sParameterKeyword - Parameter keyword
to list
-
Get parameter value at position
odaba::String BaseContext  :: parameter ( int32 iParameterCount )
The parameter is selected in the parameter list according to its position. The first parameter has position 1.
// parm string passed: "otto,paul,place=village"
parm(1): "otto"
parm(2): "paul"
parm(3): "name=village"
parm(4): ""
- iParameterCount
- Number of passed parameters
The value contains the number of parameters in a parameter list passed to an action or function. Parameters in the list might have NULL values.
to list
- iParameterCount
- Number of passed parameters