Formula Editor

The formula editor defines a formula for the field.

To enter a formula:

  • Click the 'Edit' button adjacent to the formula field.

Formulas have the syntax:

value:=expression

where expression is a mathematical formula.

eg value:=9*4.

Any field from any of the flowcomputers can be selected and can be included in the calculation.

eg value:=field("[Omni]STR01 Pressure")

Multiple fields can also be included in the calculation:

eg value:=field("[Omni]STR01 Gross Flowrate")+field([Omni]STR02 Gross Flowrate")

These fields can also come from multiple flowcomputers:

eg value:=field("[Omni 1]STN01 Gross Total")+field([Omni 2]STN01 Gross Total")

Variables can be declared and used as part of the calculation:

  • var a := 2;
  • var b := 3;
  • value := a + b;

If statements can also be written to display a value based on a Boolean expression being satisfied. The following formula returns the difference between the limit

	var temperature := field("[Omni 6000]Temperature");
	var high_temperature := field("[Omni 6000]Temp Hi-Lim");
	if (temperature > high_temperature)
	   value := temperature - high_temperature;
	else
	var low_temperature := field("[Omni 6000]Temp Lo-Lim");
		if (temperature < low_temperature)
			value := temperature - low_temperature;
		else
			value := 0;
		end if
	end if

Recursion

If you need to reference a field from within its own formula use 'value' rather than the direct field reference in order to prevent recursion.

Use the following script for the definition of "myfield":

  • value := value / 100

rather than:

  • value := field("myfield") / 100

Warning: Be careful of introducing recursion. ie a = b and b = a. Acquire will automatically substitute any reference to the field with the reference 'value' but it will not return a value for a field should it detect a recursive script.

Operators

The calculation can include any of the following operators. A full list is available in the operator popup menu.

+ plus - minus
* multiply / divide
% mod \ integer divide
= equals # not equal to
> greater than < less than
>= greater than or equal to <= less than or equal to
|| Logical OR & Logical AND
| Bitwise OR && Bitwise AND
<< Bit Rotate Left >> Bit Rotate Right
! not ? Bit Test

Inserting a Field Reference into the Formula

To insert a field on the formula entry screen:

  • Click the 'Field' button.

This will display a list of all fields for all the selected flowcomputer:

  • Select the flowcomputer from the 'Flowcomputer' popup menu.
  • Select the field either by typing in the full name, selecting it from the list or by typing a partial name and clicking the 'Go' button.
  • Click on the field in the field list to highlight it
  • Click the 'OK' button.

Testing a Formula

Once you have written your formula, you can test it to make sure that the formula's syntax is correct and that it returns the correct value.

To test the formula:

  • Enter the formula.
  • Click the 'Run' button. This will tell you if the formula was valid and will show you the value that was calculated based on current values returned from the flowcomputer
  • Click the 'OK' button.

Entering Text Descriptions

Acquire™ allows fields to have text values to be associated with the numeric values that are returned from the flowcomputer. eg 1 = Open, 2 = Closed etc.

To add a Text Description:

  • Click the 'Edit' button adjacent to the text description field.

This will open the text description window:

  • Click the 'Add' button.

  • Enter the Field Value and its corresponding description.
  • Click the 'OK' button.

In the above example, the text "Valid" will be used in place of the value "1" whenever the field is displayed in Acquire™.

Note: Field Values do not need to be sequential.






Acquire™ Editor Manual