get_comp
Purpose:
-
Display or return the value of a computed expression in the specified units.
Refer to Section 7 of “CyFlex Variables, Units, and Computed Expressions” for the rules of syntax.
Enter:
-
get_comp <expression> [u=units] [option=output options]
Where:
-
expression
Specify the expression to compute. Enclose in double quotes as shown in Examples.
u=units
Optional. Specify the units for the results of the computation and the display. The default is to use the default units.
option
Optional. Specify an output content preference:
- verbose to display output with equal signs and units. This is the default.
- simple to display output with units and without equal signs or carriage returns. This option is intended for automated scripts.
- no-units to display output without equal signs, carriage returns, and units. This option is intended for automated scripts.
Examples:
-
get_comp ” RPM * Torque” u=hp
The above command displays the current power in units of horsepower.
get_comp ” ‘date=’ + @year_month_day() “
This example demonstrates string concatenation. The single quote is used to enclose a literal string, the @year_month_day() function returns a string such ‘220217’ for Feb 17, 2022 and the + symbol is used to concatenate the 2 strings resulting in an output of
‘date=220217’
get_comp ” if( hr_meter_run ) then 100[psi] else 0[psi] ” u=psi
This example demonstrates a simple logical expression that will return either 100[psi] or 0[psi] depending on whether the logical variable ‘hr_meter_run’ is TRUE of FALSE. If the “u=psi” argument is specified, the value would be returned in units of PA (pascals).
The following illustrates different outputs based on the specified output option.
get_comp “1[in_hg] + vap_pa” u=in_h2o option=verbose= 27.1407330011252199142291[in_h2o]
get_comp “1[in_hg] + vap_pa” u=in_h2o option=simple
27.1407330011252199142291[in_h2o]get_comp “1[in_hg] + vap_pa” u=in_h2o option=no-units
27.1407330011252199142291
Notes:
-
You can wrap the [units] argument in ” ” or ‘ ‘ if you get an issue.
An example problem is:
get_comp “200[gm/kw_hr]” u=lb/(hp_hr)
returns:
bash: syntax error near unexpected token ‘(‘
To fix this, run it as follows:
get_comp “200[gm/kw_hr]” “u=lb/(hp_hr)”