Param

You can use the Param function in Optiva equations to return the value of an objects parameter using the parameters unit of measure.

Note: For concentrations or percentages, the function returns the concentration or percentage value, not the actual amount (mass) in the formula.

When to use

You can use this function to:

  • Calculate values based on parameter concentrations or percentages rather than actual amounts.
  • Retrieve parameter values at the formula level (total concentration across all ingredients).
    // Returns: "16.666" (concentration in MG/100GM)
    string concentration = Param("SODIUM");
    
    Use when: You need the parameterss concentration/percentage value for the formula
    

When not to use

You cannot use this function when:

  • You need actual amounts (mass). Use Tparam or TparamItem instead.
  • With equation-derived parameters. Use ValParam instead.

Syntax

string Param(string paramName);

Parameters

Parameter Type Required Description
paramName string Yes The name of the parameter to retrieve

Return Value

  • The application returns the parameter value as a string in its unit of measure.
  • The Param function returns a string unless you convert the value to a numeric data type before performing numeric operations.
  • For concentrations or percentages, returns the concentration or percentage value, not the actual amount (mass) of the parameter in the formula.
  • For alternate unit of measure conversions, use ObjProperty to obtain parameter values. Do not use Param or ParamItem.
  • Examples:
    • Parameter value = 50, UOM = % → Returns "50"
    • Parameter value = 16.666, UOM = MG/100GM → Returns "16.666"

Prerequisites

The function always returns a string. Convert the value for numeric operations.

Examples

Example 1
Retrieve the parameter value.
Example: CALCIUM = 100 MG/100GM at item level (rolled up to formula).
This equation divides CALCIUM by 2 and stores as CALCIUMHALF.
  1. Get CALCIUM parameter value as string and parse to double.
    double dCalcium = double.Parse(Param("CALCIUM"));
  2. Divide by 2 (100 / 2 = 50).
    double dHalf = dCalcium / 2;
  3. Convert result back to string.
    string sHalf = dHalf.ToString();
  4. Set CALCIUMHALF parameter to 50.
    int iValue = SetParam("CALCIUMHALF", sHalf);
    Note: iValue will contain status code (typically 0 for success).
Description
  • The equation returns the value of the parameter CALCIUM.
  • The value is divided by two.
  • The parameter is defined initially by an equation at the item level.
  • Then, the parameter is rolled up.
  • Assign the parameter to the lab as a rollup.
  • If the CALCIUM parameter is overridden at the formula level, then the param function uses the overridden value.
SeeDifference Between Param, ParamItem, Tparam, and TparamItem