The functions listed here can be used in expressions in the ComfileHMI editor.
Functions with a single argument:
sin
: Sinecos
: Cosinetan
: Tangentasin
: Arc-Sineacos
: Arc-Cosineatan
: Arc-Tangentsinh
: Hyperbolic Sinecosh
: Hyperbolic Cosinetanh
: Hyperbolic Tangentfloor
: Rounds number down to the nearest integer value.ceil
: Rounds number up to the nearest integer value.exp
: e raised to a given exponentlog
: Natural Logarithmlog10
: Log base 10fabs
: absolute valuesqrt
: square rootFunctions with 2 arguments:
pow(x,y)
: x raised to the power yfmod(x,y)
: the remainder of x divided by y.Functions with 5 arguments:
scale(input, minimum input, maximum input, minimum output, maximum output)
: Scales input
proportionally to (maximum input
- minimum input
) / (maximum output
- minimum output
).Functions with a variable number of arguments:
max(x,y,z,…)
: Returns the largest value from the argument listmin(x,y,z,…)
: Returns the smallest value from the argument listmax_index(x,y,z,…)
: Returns the index of the largest value in the argument listmin_index(x,y,z,…)
: Returns the index of the smallest value in the argument listavg(x,y,z,…)
: Returns the average of all values in the argument liststdev(x,y,z,…)
: Returns the standard deviation of all values in the argument listThe following functions are used to read from and write to internal memory.
set_mem(index, value)
: Writes value
to internal memory at index
.mem(index)
: Reads the value current stored in internal memory at index
.set_mem(index, value1, value2, …, valueN)
Functions associated with the system. They take no arguments.
action_group_repeat_index
: Retrieves the number of times a user event was executed.idle_seconds
: Returns the number of seconds since the screen was last touched.idle_minutes
: Returns the number of minutes since the screen was last touched.prev_screen_id
: Returns the id of the screen that the current screen navigated from.screen_id
: Returns the id of the screen the current screen.tick_count
: The number of milliseconds since the system was powered on.touch_duration
: The number of milliseconds since the last time the screen was touched. If the screen has never been touched -1 is returned.Functions to convert between data types.
text_to_num(string)
: Parses a character string in base 10.num_to_text_int(number)
: Prints a number as a base 10 integer character string.num_to_text_int(number, digits)
: Prints a number as a base 10 integer character string with leading 0's. Ex: num_to_text_int(3.14, 4)
prints “0003”.num_to_text_hex(number)
: Prints a number as a base 16 integer character string.num_to_text_hex(number, digits)
: Prints a number as a base 16 integer character string with leading 0'snum_to_text_dec(number, fractional digits)
: Prints a number as a base 10 character string with a given number of fractional digits. Ex: num_to_text_dec(3.14159, 4)
= “3.1416”In the Add Action –> Run Action Group properties, in the Advanced Options is the ability to pass a primary and secondary parameter to the actions (Add Action Parameter and Add Secondary Action Parameter respectively) .
The parameters can then be read from within the executing action using the following functions.
action_param
: Retrieves the primary parameter passed to an action.sub_action_param
: Retrieves the secondary parameter passed to an action group.Functions with no argument.
year
: The current yearmonth
: The current month (1~12)day
: The day of the monthday_of_week
: The day of the week (0~6), 0 = Sundayhour
: The hour of the day (0~23)minute
: The minute component of the current hour (0~59)second
: The second component of the current minute (0~59)rand
: returns a random number in the range of 0~32767 (0x7FFF)Functions that take 1 argument but return no value.
set_year
: Sets the current yearset_month
: Sets the current month (1~12)set_day
: Sets the day of the monthset_hour
: Sets the hour of the day (0~23)set_minute
: Sets the minute component of the current hour (0~59)set_second
: Sets the second component of the current minute (0~59)srand(seed
) : Sets the seed value for generating random numbers with the rand()
function.
It is recommended to call srand(tick_count())
to seed the random number generator before using rand()
.