You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
expression function
Arithmetic expression function
Copy page
Download PDF
Arithmetic expression function
This document describes the syntax and format of arithmetic expression functions, related scenario examples, and more. ​
op_add function ​
accumulation operation. Accumulate multiple values, values can be strings or numeric, and different value data types must be consistent. Supported calculation range: integer -2 ^ 52 + 1~ 2 ^ 52-1, floating-point number -1.8e308~ 1.8e308. ​
Function syntax/format ​
​
op_add(value1,value2)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number or String​
Yes​
/​
/​
The value to be calculated.​
Value2​
Number or String​
Yes​
/​
/​
The value to be calculated.​
​
Function example ​
Function example 1: ​
  • Scenario: Known students' scores in language, mathematics and English subjects, calculate the total score of students. ​
  • Processing rules: ​
  • ​
    f_set("total",op_add(v("math"),v("chinese"),v("english")))​
    ​
  • Log sample: ​
  • ​
    {​
    "math": 96,​
    "chinese": 98,​
    "total": 274​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "math": 96,​
    "chinese": 98,​
    "total": 274,​
    "english": 80​
    }​
    ​
Function example 2: ​
  • Scenario: According to the province, city and county streets, splicing out the detailed address. ​
  • Processing rules: ​
  • ​
    f_set("address",op_add("address:",v("province"),v("city"),v("town"),v("detail")))​
    ​
  • Log sample: ​
  • ​
    {​
    "province": "Sichuan province",​
    "city": "Chengdu city",​
    "town": "Wuhou town",​
    "detail": "231 Hao, Wuhouci street"​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "province": "Sichuan province",​
    "city": "Chengdu city",​
    "town": "Wuhou town",​
    "detail": "231 Hao, Wuhouci street",​
    "address": "Address:231 Hao, Wuhouci street, Wuhou town, Chengdu city, Sichuan province"​
    }​
    ​
op_sub function ​
subtraction operation. Returns the difference between value1 and value2. ​
Function syntax/format ​
​
op_sub(value1,value2)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number​
Yes​
/​
/​
The value to be calculated.​
Value2​
Number​
Yes​
/​
/​
The value to be calculated.​
​
Function example ​
  • scenario: The total number of employees is 100, of which 48 are male, and the number of women is calculated. ​
  • Processing rules: ​
  • ​
    f_set("female",op_sub(v("total"),v("man")))​
    ​
  • Log sample: ​
  • ​
    {​
    "total": 100,​
    "female": 52​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "total": 100,​
    "female": 52,​
    "man": 48​
    }​
    ​
op_mul function ​
multiplication operation. Multiplication calculation returns the product of value1 and value2. ​
Function syntax/format ​
​
op_mul(value1,value2)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number​
Yes​
/​
/​
The value to be calculated.​
Value2​
Number​
Yes​
/​
/​
The value to be calculated.​
​
Function example ​
  • scenario: speed times time to calculate the distance. ​
  • Processing rules: ​
  • ​
    f_set("distance",op_mul(v("speed"),v("time")))​
    ​
  • Log sample: ​
  • ​
    {​
    "speed": 60,​
    "time": 8​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "distance": 480,​
    "speed": 60,​
    "time": 8​
    }​
    ​
op_div function ​
division operation. Returns the quotient of value1 divided by value2, the divisor value2 cannot be 0. ​
Function syntax/format ​
​
op_add(value1,value2)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number​
Yes​
/​
/​
The value to be calculated.​
Value2​
Number​
Yes​
/​
/​
The value to be calculated.​
​
Function example ​
  • scenario: total consumption amount/number of people calculation per capita consumption ​
  • Processing rules: ​
  • ​
    f_set("avg_cost",op_mul(v("cost"),v("people")))​
    ​
  • log sample: ​
  • ​
    {​
    "cost": 1500,​
    "avg_cost": 150​
    }​
    ​
  • Processing results: ​
  • ​
    {​
    "cost": 1500,​
    "avg_cost": 150,​
    "people": 10​
    }​
    ​
op_sum function ​
addition operation. Returns the sum of value1 and value2, where value is a variable parameter that can compute multiple values. ​
Function syntax/format ​
​
op_sum(value1,value2...)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number​
Yes​
/​
/​
The value to be added.​
Value2​
Number​
Yes​
/​
/​
The value to be added.​
​
Function example ​
  • scenario: bill storage cost 150, traffic cost 100, search cost 200, total cost 450. ​
  • Processing rules: ​
  • ​
    f_set("total_cost",op_sum(v("storage_cost"),v("flow_cost"),v("search_cost")))​
    ​
  • Log sample: ​
  • ​
    {​
    "storage_cost": 150,​
    "flow_cost": 100,​
    "total_cost": 450​
    }​
    ​
  • Processing results: ​
  • ​
    {​
    "storage_cost": 150,​
    "flow_cost": 100,​
    "total_cost": 450,​
    "search_cost": 200​
    }​
    ​
op_mod function ​
remainder calculation. Returns the remainder of value1 divided by value2. ​
Function syntax/format ​
​
op_add(value1,value2)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value1​
Number​
Yes​
/​
/​
Divisor.​
Value2​
Number​
Yes​
/​
/​
Divisor.​
​
Function example ​
  • scenario: 10 afternoon tea, each person divided into three, calculate the remaining number of copies 1. ​
  • Processing rules: ​
  • ​
    f_set("remand",op_sum(v("total"),v("avg")))​
    ​
  • Log sample: ​
  • ​
    {​
    "total": 10,​
    "remand": 1​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "total": 10,​
    "remand": 1,​
    "avg": 3​
    }​
    ​
op_null function ​
determines whether it is empty. Returns the bool value. True if value is empty or the None keyword, False otherwise. ​
Function syntax/format ​
​
op_null(value)​
​
parameters are described as follows: ​
​
Parameter​
Parameter type​
Required​
Default value​
Value range​
Description​
Value​
Number​
Yes​
/​
/​
Value to be judged.​
​
Function example ​
Function example 1: ​
  • Scenario: None keyword is empty. ​
  • Processing rule: ​
  • ​
    f_set("op_null",op_null(None))​
    ​
  • Log sample: ​
  • ​
    {​
    "region_id": 1,​
    "region": "beijing"​
    }​
    ​
  • Processing result: ​
  • ​
    {​
    "region_id": 1,​
    "op_null": "true",​
    "region": "beijing"​
    }​
    ​
Function example 2: ​
  • Scenario: region field is not empty. ​
  • Processing rules: ​
  • ​
    f_set("region_null",op_null(v("region")))​
    ​
  • Log example: ​
  • ​
    {​
    "region_id": 1,​
    "region": "beijing"​
    }​
    ​
  • Processing results: ​
  • ​
    {​
    "region_id": 1,​
    "op_null": "false",​
    "region": "beijing"​
    }​
    ​
​
​
Last updated: 2026.07.01 15:59:38