分享

计算字段命令,FUNCTION功能

 风情个人图书馆 2016-12-10

在计算字段中有一种命令性的功能,可以写到计算公式上,它相当于非常简化的计算公式。

总体上分为4类:

MATH(数学):差不多可以肯定都是一些函数。

DATE / TIME(日期/时间): 得到的都是日期时间结果。

STRINGS(字符串): 不明觉厉。

LOGICAL(逻辑): 相当于自定义写判断公式。

如需查看更多计算函数或功能实例,查看更多计算函数及功能

MATH(数学)

abs()

Absolute value of a double value.

返回数的绝对值。

语法

 abs(x)

实例 在本例中,我将取得正数和负数的绝对值:

abs(7.25)
abs(-7.25)
abs(7.25-10)

输出:

7.25
7.25
2.75

acos()

Arc cosine of an angle.

返回数的反余弦值。

语法

 acos(x)

x 必需。必须是 -1.0 ~ 1.0 之间的数。

'返回值'

x 的反余弦值。返回的值是 0 到 PI 之间的弧度值。

'提示和注释'

注释:如果参数 x 超过了 -1.0 ~ 1.0 的范围,那么浏览器将返回 NaN。

注释:如果参数 x 取值 -1,那么将返回 PI。

'实例'

在本例中,我们将取得不同数的反余弦值:

 acos(0.64)
 acos(0)
 acos(-1)
 acos(1)
 acos(2)

输出:

 0.8762980611683406
 1.5707963267948965
 3.141592653589793
 0
 NaN

asin()

返回数的反正弦值。

语法 </file> asin(x) </file> x 必需。必须是一个数值,该值介于 -1.0 ~ 1.0 之间。

'返回值'

x 的反正弦值。返回的值是 -PI/2 到 PI/2 之间的弧度值。

'提示和注释'

注释:如果参数 x 超过了 -1.0 ~ 1.0 的范围,那么浏览器将返回 NaN。

注释:如果参数 x 取值 1,那么将返回 PI/2。

'实例'

在本例中,我们将取得不同数字的反正弦值:

 asin(0.64) 
 asin(0) 
 asin(-1) 
 asin(1)
 asin(2)

输出:

 0.6944982656265559
 0
 -1.5707963267948965
 1.5707963267948965
 NaN

atan()

Arc tangent of an angle.

返回数字的反正切值。

'语法'

atan(x)

x 必需。必须是一个数值。

'返回值'

x 的反正切值。返回的值是 -PI/2 到 PI/2 之间的弧度值。

'实例'

下面这个例子可通过 atan() 方法返回不同数字的反正切值:

 atan(0.50)
 atan(-0.50)
 atan(5)
 atan(10)
 atan(-5)
 atan(-10)

输出:

 0.4636476090008061
 -0.4636476090008061
 1.373400766945016
 1.4711276743037347
 -1.373400766945016
 -1.4711276743037347

atan2(,)

The function converts rectangular coordinates to polar

返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间)。

'定义和用法'

atan2() 方法可返回从 x 轴到点 (x,y) 之间的角度。

'语法'

 atan2(y,x)参数 描述 

x 必需。

指定点的 X 坐标。

y 必需。

指定点的 Y 坐标。

'返回值'

-PI 到 PI 之间的值,是从 X 轴正向逆时针旋转到点 (x,y) 时经过的角度。

'提示和注释'

注释:请注意这个函数的参数顺序,Y 坐标在 X 坐标之前传递。

'实例'

下面这个例子可通过 atan2() 方法返回不同 (x,y) 点的角度:

 atan2(0.50,0.50)
 atan2(-0.50,-0.50)
 atan2(5,5)
 atan2(10,20)
 atan2(-5,-5)
 atan2(-10,10)

'输出'

 0.7853981633974483
 -2.356194490192345
 0.7853981633974483
 0.4636476090008061
 -2.356194490192345
 -0.7853981633974483

ceil()

Ceiling value of a double value

对数进行上舍入

'定义和用法'

ceil() 方法可对一个数进行上舍入。

'语法'

 ceil(x)

参数 描述

x 必需。必须是一个数值。

'返回值'

大于等于 x,并且与它最接近的整数。

说明 ceil() 方法执行的是向上取整计算,它返回的是大于或等于函数参数,并且与之最接近的整数。

'实例'

在本例中,我们将把 ceil() 方法运用到不同的数字上:

 ceil(0.60)
 ceil(0.40)
 ceil(5)
 ceil(5.1)
 ceil(-5.1)
 ceil(-5.9))

'输出'

 1
 1
 5
 6
 -5
 -5

cos()

Trigononmetric cosine of an angle

返回数的余弦。

'定义和用法'

cos() 方法可返回一个数字的余弦值。

'语法'

 cos(x)

参数 描述

x 必需。

必须是一个数值。

'返回值'

x 的余弦值。

返回的是 -1.0 到 1.0 之间的数。

'实例'

在本例中,我们将返回不同数值的余弦值:

 cos(3)
 cos(-3)
 cos(0)
 cos( PI)
 cos(2* PI))

'输出'

 -0.9899924966004454
 -0.9899924966004454
 1
 -1
 1

exp()

Exponential number e (i.e.,2.718…)raised to the power of a double value.

返回 e 的指数。

'定义和用法'

exp() 方法可返回 e 的 x 次幂的值。

'语法'

 exp(x)

参数 描述

x 必需。

任意数值或表达式。

被用作指数。

'返回值'

返回 e 的 x 次幂。

e 代表自然对数的底数,其值近似为 2.71828。

'实例'

在下面的例子中,我们将把 exp() 运用到不同的数值上:

 exp(1)
 exp(-1)
 exp(5)
 exp(10)

'输出'

 2.718281828459045
 0.36787944117144233
 148.4131591025766
 22026.465794806718

log()

Natural logarithm (base e) of a double value

返回数的自然对数(底为e)。

'定义和用法'

log() 方法可返回一个数的自然对数。

'语法'

 log(x)

参数 描述

x 必需。任意数值或表达式。

'返回值'

x 的自然对数。

说明

参数 x 必须大于 0。

'实例'

在本例中,我们将对不同的数运用 log() :

 log(2.7183)
 log(2)
 log(1)
 log(0)
 log(-1))

'输出'

 1.0000066849139877
 0.6931471805599453
 0
 -Infinity
 NaN

max(,)

最大(,)

返回 x 和 y 中的最高值。

示例

字段:数一(56)、数二(89) max(#(数一),#(数二)) 结果 89

'定义和用法'

 max() 

方法可返回两个指定的数中带有较大的值的那个数。

'语法'

 max(x...)

参数 描述

x 0 或多个值。在 ECMASCript v3 之前,该方法只有两个参数。

'返回值'

参数中最大的值。

如果没有参数,则返回 -Infinity。

如果有某个参数为 NaN,或是不能转换成数字的非数字值,则返回 NaN。

'实例'

在本例中,我们将展示如何使用 max() 来返回指定数字中带有最高值的数字:

 max(5,7)
 max(-3,5)
 max(-3,-5)
 max(7.25,7.30))

'输出'

 7
 5
 -3
 7.3

min(,)

Smaller of two double values

回 x 和 y 中的最低值。

示例

字段:数一(56)、数二(89) min(#(数一),#(数二)) 结果 56

'定义和用法'

min() 方法可返回指定的数字中带有最低值的数字。

'语法'

 min(x,y)

参数 描述

x 0 或多个值。

在 ECMASCript v3 之前,该方法只有两个参数。

'返回值'

参数中最小的值。

如果没有参数,则返回 Infinity。

如果有某个参数为 NaN,或是不能转换成数字的非数字值,则返回 NaN。

'实例'

在本例中,我们将展示如何使用 min() 来返回指定数字中带有最低值的数字:

 min(5,7)
 min(-3,5)
 min(-3,-5)
 min(7.25,7.30))

'输出'

 5
 -3
 -5
 7.25

pow(,)

Value of the first argument raised to the second power of the second argument

返回 x 的 y 次幂。

'定义和用法'

pow() 方法可返回 x 的 y 次幂的值。

'语法'

 pow(x,y)

参数 描述

x 必需。底数。必须是数字。

y 必需。幂数。必须是数字。

'返回值'

x 的 y 次幂。

'说明'

如果结果是虚数或负数,则该方法将返回 NaN。

如果由于指数过大而引起浮点溢出,则该方法将返回 Infinity。

'实例'

在下面的例子中,我们将把 pow() 运用到不同的数字组合上:

 pow(0,0)
 pow(0,1)
 pow(1,1)
 pow(1,10)
 pow(2,3)
 pow(-2,3)
 pow(2,4)
 pow(-2,4)

'输出'

 1
 0
 1
 1
 8
 -8
 16
 16

rint()

Double value that is closest in value to the argument and is equal to a mathematical integer

值与参数值最为接近的一个值,并与一个数学整数相等

round()

Closet long to a doouble vallue

把数四舍五入为最接近的整数。

'定义和用法'

round() 方法可把一个数字舍入为最接近的整数。

'语法'

 round(x)

参数 描述

x 必需。必须是数字。

'返回值'

与 x 最接近的整数。

'说明'

对于 0.5,该方法将进行上舍入。

例如,3.5 将舍入为 4,而 -3.5 将舍入为 -3。

'实例'

把不同的数舍入为最接近的整数:

 round(0.60)
 round(0.50)
 round(0.49)
 round(-4.40)
 round(-4.60))

'输出'

 1
 1
 0
 -4
 -5

sin()

Sine of an angle

返回数的正弦。

'定义和用法'

sin() 方法可返回一个数字的正弦。

'语法'

 sin(x)

参数 描述

x 必需。一个以弧度表示的角。将角度乘以 0.017453293 (2PI/360)即可转换为弧度。

'返回值'

参数 x 的正弦值。

'返回值'

在 -1.0 到 1.0 之间。

'实例'

在本例中,我们将返回不同数字的正弦:

 sin(3)
 sin(-3)
 sin(0)
 sin( PI)
 sin( PI/2)

'输出'

 0.1411200080598672
 -0.1411200080598672
 0
 1.2246063538223772e-16
 1

sqrt()

A square root of a double value

返回数的平方根。

'定义和用法'

sqrt() 方法可返回一个数的平方根。

'语法'

 sqrt(x)

参数 描述

x 必需。必须是大于等于 0 的数。

'返回值'

参数 x 的平方根。如果 x 小于 0,则返回 NaN。

'提示和注释'

提示: pow() 方法可以计算一个数的任意次根。

'实例'

在本例中,我们将返回不同数字的平方根:

 sqrt(0)
 sqrt(1)
 sqrt(9);
 sqrt(0.64)
 sqrt(-9)

'输出'

 0
 1
 3
 0.8
 NaN

tan()

Trigonometric tangent of an angle

返回角的正切。

'定义和用法'

tan() 方法可返回一个表示某个角的正切的数字。

'语法'

 tan(x)

参数 描述

x 必需。一个以弧度表示的角。将角度乘以 0.017453293 (2PI/360)即可转换为弧度。

'返回值'

参数 x 的正切值。

'实例'

在本例中,我们将计算不同数字的正切值:

 tan(0.50)
 tan(-0.50)
 tan(5)
 tan(10)
 tan(-5)
 tan(-10))

'输出'

 0.5463024898437905
 -0.5463024898437905
 -3.380515006246586
 0.6483608274590866
 3.380515006246586
 -0.6483608274590866

todegrees()

The function converts an angle an angle measured in radians to the equivalent angle measured in degrees

该函数将一个角度测量角度弧度衡量度等效的角度

toradians()

The function converts an angle measured in degress to the equivalent angle measured in radians.

该函数将一个测量角度的弧度的等效角度测量。

DATE/TIME(日期/时间)

datediff(,)

Number of days between two dates.

日期之间的天数。

示例

字段:日期1(2016年3月23日 下午2:09)、日期2(2016年3月26日 下午3:09)

 datediff(#(日期1),#(日期2))

结果 3

dateadd(,)

The dateadd function adds a specified time interval to a date.The function accepts fou arguments:(date field,days,months,years)or seven(date field,seconds,minutes,hours,days,months,years)

DateAdd函数添加一个指定的时间间隔的日期。该函数接受基础参数:(日期字段,天,月,年)或七(日期字段,秒,分钟,小时,天,月,年)

formatDate()

Converts seconds to a string as a date

将秒转换为日期

字段:日期时间1 2016年3月23日 下午2:09

 formatdate(#(日期时间1))

结果

 lnvalid double:"2016年3月23日"

formatDate Time()

time() formatdate

Converts seconds to a string as a date and time

将秒转换为日期和时间

formatTime()

Converts seconds to a string as a time

把秒到一个字符串作为时间

字段:时间1 下午6:00 结果

 lnvalid double:"上午2:00"

now()

Returns the current time in seconds since january 1,1970 00:00:00.0 UTC.This method always returns UTC times,regardless of the system's time zone.

返回自一月11970 00:00:00.0 UTC秒当前时间。这个方法总是返回UTC时间,无论系统的时区。

结果

 1458730667

ralativetimestr()

Returns a string describing the elapsed time since startTime.The function accept one argument??startTime - some time in the past.

返回一个描述以来经过的时间开始时间字符串,函数接受一个参数??StartTime -在过去的一段时间。

字段:日期时间1 2016年3月23日 下午2:09

 ralativetimestr(#(日期时间1))

结果

 lnvalid double:"4小时前"

字段:日期时间2 2016年3月26日 下午3:09

 ralativetimestr(#(日期时间2))

结果

 lnvalid double:"3天后"

formatduration()

Formats a duration time in the form MM:SS or H:MM:SS. The function accept on argument:seconds.

在表单中格式化一个持续时间:不锈钢或小时:不锈钢。在参数上接受的功能:秒。

字段:时间2 下午6:30

 formatduration(#(时间2))

结果

 lnvalid double:"18:30:00"

STRINGS(字符串)

numtostr()

Convert number to string

将数字转换为字符串

字段:数一 56

 numtostr(#(数一))

结果

 56

compareTo(,)

The function compares two strings lexicographically.

函数比较两个字符串的字典。

Parameters:The first argumnet is the first string to compare and the second argument is the second string to compare.

参数:第一argumnet是要比较的第一个字符串和第二比较二串。

Returns:Retruns an integer value of zero if the strings are equal,an integer value less than zero if the firs string precedes the second string or an integer value greater than zero if the first string follows the second string.

收益:收益为零的整数,如果字符串相等,一个整型值小于零,如果第一弦先于第二字符串或整数的值大于零,如果第二字符串如下第一个字符串。

compareTolgnoreCase(,)

The function compares two strings lexicographically,ignoreing case considerations.

函数比较两个字符串字典,忽视案例的思考。

Parameters:The first argumnet is the first string to compare and the second argument is the second string to compare.

参数:第一argumnet是要比较的第一个字符串和第二比较二串。

Returns:Retruns an integer value of zero if the strings are equal,an integer value less than zero if the firs string precedes the second string or an integer value greater than zero if the first string follows the second string.

收益:收益为零的整数,如果字符串相等,一个整型值小于零,如果第一弦先于第二字符串或整数的值大于零,如果第二字符串如下第一个字符串。

concat(,)

The fuction concatenates the second string to the end of the first.

连接字符串。

Parameters:The first argument is the string in which the second argument string will be concatenated.

参数:第一个参数是一个字符串,其中二个参数字符串将被连接起来。

Returns:Returns a string that is made up the first string,followed by the second string.

返回:返回一个字符串,该字符串是由第一个字符串组成的,其次是第二个字符串。

endsWith(,,)

The functiontests if the string ends with a speecified suffix.

的功能如果字符串的结尾是一个speecified后缀。

Parameters:The first argument is the string to test and second argument is the suffix.

参数:第一个参数是字符串,测试和第二个参数是后缀。

Returns:Refturns 1.0(true) if the string ends with the suffix,otherwise it returns 0.0 (false).

返回:refturns 1(真的)如果字符串结尾的后缀,否则返回0(假)。

equals(,)

The function tests one string equals another.

函数测试一个字符串等于另一个字符串。

Parameters:The first argument is a string that will be compared to the second argument string.

参数:第一个参数是一个字符串,将与第二个参数字符串进行比较。

Returns:Returns 1.0(true) if the strings is equals,otherwise it returns 0.0(false).

返回:返回1(真),如果字符串是相等的,否则返回0(假)。

equalslgnoreCase(,)

The function tests one string equals another,but ignores case.

函数测试一个字符串等于另一个,但忽略了案例。

Parameters:The first argument is a string that will be compared to the second argument string.

参数:第一个参数是一个字符串,将与第二个参数字符串进行比较。

Returns:Returns 1.0(true) if the strings is equals,otherwise it returns 0.0(false).

返回:返回1(真),如果字符串是相等的,否则返回0(假)。

indexOf(,,)

The function returns the index within the source string of the first occurrence of the substring,sarting at the specified index.

返回某个指定的字符串值在字符串中首次出现的位置。

Parameters:The first argument is the source string,the second argument is the substring and the third argument is the index.

参数:第一个参数是字符串,第二个参数是字符串,第三个参数是指标。

Returns:Returns The index at wher the substring is found.if the substring is not found.then -1 is retruned.

返回:返回的字符串是在指数在found.if子字符串不是3 - 1是函数返回。

length()

The function returns the length length of the source string

函数返回源字符串的长度长度

replace(,,)

The fuction returns a new string with all of the occurances of the old character in the source string replaced with the new character.

替换与正则表达式匹配的子串。

Parameters:The first argument is the source string to replace the charactes in.The second argument is the old character to replace in the source string.The third argument is the new character to replace the old character with in the source string.

参数:第一个参数是源字符串替换的特征,二是在源字符串替换旧的性格。第三个参数来代替旧的角色在源字符串的新特征。

Returns:Retruns a string with every occurence of the old character replaced with the new character.

收益:收益与新角色取代了旧的角色的每一个发生的字符串。

startsWith(,,)

The function tests if the string starts with a specified prefix beginning at a specified index.

函数测试如果字符串以一个指定的索引开始时开始。

Parameters:The first argument is the string to test,the second argument is the prefix and the third argument is the index to start at.

参数:第一个参数是字符串,二个参数是前缀,第三个参数是开始的索引。

Returns:Returns 1.0(true) if the string starts with the prefix,otherwise it returns 0.0 (false).

返回:返回1(真),如果字符串以前缀开头,则返回0(假)。

substrin(,,)

The function returns a string that is a substring of the source string.

该函数返回一个字符串,字符串的子字符串的源程序。

Parameters:The first argument is the source string,the second argument is the beginning index and the third argument is the ending index.

参数:第一个参数是源字符串,其次是开始索引,第三个参数是结束索引。

Retruns:Returns the specified substring.

收益:返回指定的子字符串。

tolowercase()

The function returns the source string in lower case.

把字符串转换为小写。

'定义和用法'

tolowercase() 方法用于把字符串转换为小写。

'语法'

 tolowercase()

'返回值'

一个新的字符串,在其中 stringObject 的所有大写字符全部被转换为了小写字符。

'实例'

在本例中,“Hello world!” 将以小写字母来显示:

 tolowercase("Hello World!")

touppercase()

The fuction returns the source string in upper case.

把字符串转换为大写。

'定义和用法'

touppercase()

方法用于把字符串转换为大写。

'语法'

 touppercase()

'返回值'

一个新的字符串,在其中 stringObject 的所有小写字符全部被转换为了大写字符。

'实例'

在本例中,“Hello world!” 将以大写字母来显示:

 touppercase("Hello World!")

trim()

The function returns the source string with white space removed from both ends.

该函数返回从两个端移的空白的源字符串。

LOGICAL(逻辑)

if(,,)

如果(,)

Returns one value if a logical expression is TRUE (not equals 0.0)and another if it is FALSE (equals 0.0)

返回一个值,如果一个逻辑表达式为真(不等于0),另一个值为假(等于0)

 if( #{Time} > now() , rint((#{Time} - now())/(60*60*24)) , 'in the past')

第一个参数是条件,可以是运算公式,第二个参数是运算为真时,才运行第2个参数;第三个参数为假,运算为假时,才运行第三个。

switch(,,,)

用途
判断

理解
switch(字段或公式,
参数二,参数三,
……
……
尾部参数)

解释
参数一:可以是字段或公式
参数二:是公式的结果是否等于它
参数三:是参数二的结果
可类推添加多个判断,如同参数二
和参数三。
尾部参数:当所有判断都不等于时,所输出的结果。

实例:

switch(1+1,
1,'等于1',
2,'等于2',
3,'等于3',
'都不等于' )

也可以写到一起

switch(1+1,1,'等于1',2,'等于2',3,'等于3','都不等于' )

输出
等于2

官方示例

 switch(#(field),1,'one',2,'two','many')

示例 字段:数一(56)

 switch(#(数一),89,'是的','不是')

结果

 lnvalid double:"不是"
 
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约