| 
     << Click to Display Table of Contents >> 全局函数 | 
    
    
     ![]() ![]()  
     | 
  
函数  | 
说明  | 
举例  | 
|---|---|---|
newInstance  | 
创建一个对象实例。newInstance (String classname);  | 
var a=newInstance(query);  | 
isNull  | 
检测对象是否为空。isNull (Object obj);  | 
var a=isNull(query);  | 
isNumber  | 
检测对象是否是数值类型的。isNumber(Object val);  | 
var a=isNumber(query);  | 
isDate  | 
检测对象是否是日期类型的。isDate(Object val)  | 
var a=isDate(sell_date);  | 
getWeek  | 
从 Date 对象返回一年中的第几周 。  | 
var d = new Date("July 10, 2012 01:15:00"); var a=getWeek(d);  | 
getDate  | 
返回一个java的日期  | 
var d = new Date("July 21, 1983 01:15:00"); var a=getDate(d);  | 
cloneDate  | 
复制日期  | 
var d = new Date("July 21, 1983 01:15:00"); var a=cloneDate(d);  | 
formatDate  | 
给日期设定显示格式。formatDate(Object val,String fmtstr);  | 
var date= new Date("July 21, 1983 01:15:00"); var a=formatDate(date,"yyyy-MM-dd mm:hh");  | 
parseDate  | 
解析一个日期的字符串,并返回该日期距1970年1月1日午夜之间的毫秒数  | 
var str = "1991-10-01"; parseDate(str, "yyyy-MM-dd");  | 
dateAdd  | 
dateAdd用来给日期添加指定时间间隔  | 
var date= new Date("July 21, 1983 01:15:00"); var d=dateAdd(date,"month",1);//增加一月  | 
dateGap  | 
两个日期之间的时间差,支持year /quarter/month/weekofyear(dayofweek)/ dayofyear(dayofmonth) /hour minute /second  | 
var date= new Date("July 21, 2012 01:15:00"); var date2= new Date("June 10, 2012 01:15:00"); var a =dateGap(date,date2,"month");  | 
datePart  | 
取出年、月、日等各部分的数值  | 
var date= new Date("July 21, 1983 01:15:00"); var a=datePart(date,"year");//a=1983  | 
split  | 
把字符串分割为字符串数组。split(String str, String delim, Object limit);  | 
var str="How are you doing today?"; var b=str.split(" "); 结果为How,are,you,doing,today?  | 
split2Array  | 
将字符串分割为字符串数组。  | 
var a ="How are you"; var b=split2Array(a,2);  | 
formatNumber  | 
函数可返回作为数字被格式化的表达式。  | 
var a =formatNumber(498.8573945,"#,##0.##");就可以输出:498.86  | 
toString  | 
可把一个逻辑值转换为字符串,并返回结果。  | 
var b=2.34; var a =toString(b);  | 
substring  | 
返回一个新的字符串,它是此字符串的一个子字符串。  | 
var b=”Hello world”; var a =b.substring(0,3);  | 
sqr  | 
对数据求平方。sqr(Object val);  | 
var a=sqr(2);//a=4  | 
sqrt  | 
返回给定数据的平方根。 sqrt(9);  | 
var a=sqrt(9);//a=3  | 
abs  | 
返回给定数据的绝对值。 abs(-7);  | 
var a=abs(-7);//a=7  | 
debug  | 
向记录文件打印信息。debug(Object msg);l  | 
debug("msg");  | 
execute  | 
运行出一个查询。execute (Scriptable script, int type, String path)//Scriptale script是脚本的作用域,type是查询的类型  | 
var data=execute(this, Embed, "query1");  | 
preExecute  | 
先预编译出一个查询 preExecute(Scriptablescript,inttype,Stringpath,Object allcols)  | 
var a=preExecute(this,SQL,"data",true); var b=executed(a); setData("表1",b,DATA);  | 
executed  | 
运行出预编译出一个查询 executed(Object executedID)  | 
var a=preExecute(this,SQL,"data",true); var b=executed(a); setData("表1",b,DATA);  | 
removeExecuted  | 
删除预编译出的查询 removeExecuted(Object executedID)  | 
var a=preExecute(this,SQL,"data",true); var b=removeExecuted(a); var c=executed(a); setData("表1",c,DATA);  | 
join  | 
连接两个数据,将两个查询做连接。join(Scriptable scope, int jhint, int jop, Object jleft, Object jright, Object jlkeys, Object jrkeys, Object jlcols, Object jrcols)  | 
例如:join(this, FINAL_JOIN | LEFT_MAIN, LEFT_JOIN, lt, rt, lkeys, rkeys, lcols, rcols);  | 
union  | 
合并两个数据网,将多个数据网做合并,求交集。union (Scriptable scope, Object ugrids)  | 
Union(this, [a, b]);  | 
columns  | 
从数据网中提取出N列组成新的数据网。columns (Scriptable scope, Object cgrid, Object ccols)  | 
columns(this, query1, [3,1] );//把query1中的第3和第1列取出形成新的数据网  | 
sort  | 
对数据网特定的数据段进行排序。sort (Scriptable scope, Object sgrid, Object scols, Object sascs)  | 
sort(this, query1, [3,1], [SORT_DESC, SORT_ASC]);//先第3列降序,再第1列升序。  | 
embed  | 
数组转换为内嵌查询。embed(Object val)  | 
var a=[["编号","2","3"],["姓","wang","yao"]]; var b=embed(a); setData("表1",b,DATA);  | 
toArray  | 
查询中的列转换为数组。toArray(Object gobj,Object cobj)  | 
var query1=execute(this,SQL, 'coffee3'); var a=toArray(query1,"product"); data=compare("Decaf Espresso",a[0]);  | 
position  | 
把经度和纬度转化为一个长整型来存储。 position(Object ox, Object oy)  | 
position(10, 10);  | 
putGlobal  | 
全局常量。putGlobal(String key,Object val)  | 
putGlobal("a",1) var c=a;  | 
toSQLDate  | 
普通日期转换为SQL支持的时间戳  | 
var a=new Date("January 12,2006 22:19:35"); var b=toSQLDate(a, DType.TIME).toString();  | 
indexOf  | 
返回某个指定的字符串值在字符串中首次出现的位置  | 
var a="my hello world!" var b=a.indexOf("hello");  | 
substring  | 
返回某个指定位置的字符串的子集。  | 
var a = "Hello World"; substring(a, 1, 3);  | 
toDate  | 
将后台取到的时间转换为另一种时间  | 
var a=param["date"]; var b=toDate(a).toString().substring(0,10);  | 
aggregates  | 
对数据结果进行分组合计组成新的数据结果  | 
var a = execute(this, SQL, "Coffee"); var bcol1 = new BCol("TYPE", STRING, true); var bcol2 = new BCol("COGS", DOUBLE, false); var dimCol = new DimCol(bcol1); var meaCol = new MeasureCol(SUM, bcol2, null); var b = aggregates(this, a,[dimCol],[meaCol]) setData("表1", b, DATA);  |