ph_getvar_n PowerHome formula function
Description
Retrieves the specified system variable as a number.
Syntax
ph_getvar_n ( type, num )
Argument |
Description |
type
|
Integer. The type of system variable you wish
to retrieve. Valid values are 1, 2, 3, and 4. A 1 specifies that you wish
to retrieve LOCAL variables (the same as system variables LOCAL1 thru
LOCAL10), a 2 specifies that you wish to retrieve TEMP variables (the same
as system variables TEMP1 thru TEMP10), and a 3 specifies that you wish to
retrieve GLOBAL variables (the same as system variables GLOBAL1 thru GLOBAL20). A value of 4 is a special case and represents data that is only available during the execution of Analog I/O formulas (the Calculated to Raw and Raw to Calculated formulas). Use a num value of 1 to return raw value as a number. Use a num value of 2 to return the calc value of the Analog device as a number. This would look like ph_getvar_n(4,1) and ph_getvar_n(4,2). |
num
|
Integer. The number of the specified system variable type you wish to retrieve. To retrieve system variable TEMP7 use ph_getvar_n(2,7). |
Return value
Double. The data stored within the specified system variable returned as a double. You should be certain that the system variable contains data that can be properly converted to a numeric value.
Examples
The following examples demonstrate typical syntax/ usage for this function.
• ph_getvar_n (1,2) --> get the value in LOCAL2. The result is returned as a number, eg --> If LOCAL2 contained the string "42.65" the value returned would be the number 42.65.
• ph_getvar_n (2,4) --> get the value in TEMP4.