Equation Script

Example 1
Equation script to read the parameters "FATS_UNSAT" and "FATS_SAT", converts them to doubles, and adds them together.
using System;
using System.Diagnostics;
using System.Globalization;
using Formation.Shared.Utility;
using Formation.Server.Application.Core;
using Formation.Server.Application.Lab;

public class EquationScript : FcProcFuncSetEq
{
    public long evaluate()
    {
        double dFATS_UNSAT = Convert.ToDouble(Equation.Param("FATS_UNSAT"), CultureInfo.InvariantCulture);
        double dFATS_SAT   = Convert.ToDouble(Equation.Param("FATS_SAT"),   CultureInfo.InvariantCulture);

        // Load the parameter's value into Context.ReturnValue
        Context.ReturnValue = (dFATS_UNSAT + dFATS_SAT).ToString(CultureInfo.InvariantCulture);

        return 1L;
    }
}
Example 2
Computes TARGET_MARGIN_FC as TARGET_PRICE_FC minus TARGET_COST_FC, removing the TARGET_MARGIN_FC property if either input is missing.
  1. Reads PARAMs "TARGET_PRICE_FC" and "TARGET_COST_FC"; if either is missing it calls ObjPropertyRemove to remove "TARGET_MARGIN_FC".
  2. Otherwise computes price - cost and stores the numeric difference (as a string) in Context.ReturnValue, then returns 1.
using System;
using System.Diagnostics;
using Microsoft.VisualBasic;

public class EquationScript : FcProcFuncSetEq
{
    public long Evaluate()
    {
        string price = Param("TARGET_PRICE_FC");
        string cost = Param("TARGET_COST_FC");

        if (string.IsNullOrEmpty(price) || string.IsNullOrEmpty(cost))
        {
            ObjPropertyRemove(0, "VALUE.TPALL", "", "", "TARGET_MARGIN_FC", 2);
        }
        else
        {
            Context.ReturnValue = (Convert.ToDouble(price) - Convert.ToDouble(cost)).ToString();
        }

        return 1;
    }
}