| 
    << Click to Display Table of Contents >> Global Function | 
    
    
     ![]() ![]()  
     | 
  
Function  | 
Description  | 
Example  | 
|---|---|---|
newInstance  | 
Create an object instance. newInstance (String classname);  | 
var a=newInstance(query);  | 
isNull  | 
Check if the object is null. isNull (Object obj);  | 
var a=isNull(query);  | 
isNumber  | 
Check if the object is numeric. isNumber(Object val);  | 
var a=isNumber(query);  | 
isDate  | 
Check if the object is of date type. isDate(Object val)  | 
var a=isDate(sell_date);  | 
getWeek  | 
Returns the week of the year from the Date object.  | 
var d = new Date("July 10, 2012 01:15:00"); var a=getWeek(d);  | 
getDate  | 
Returns a java date  | 
var d = new Date("July 21, 1983 01:15:00"); var a=getDate(d);  | 
cloneDate  | 
Copy date  | 
var d = new Date("July 21, 1983 01:15:00"); var a=cloneDate(d);  | 
formatDate  | 
Set the display format for the date. 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  | 
A string that resolves a date and returns the number of milliseconds between that date and midnight on January 1, 1970  | 
var str = "1991-10-01"; parseDate(str, "yyyy-MM-dd");  | 
dateAdd  | 
dateAdd is used to add a specified time interval to the date  | 
var date= new Date("July 21, 1983 01:15:00"); var d=dateAdd(date,"month",1);//增加一月  | 
dateGap  | 
The difference between the two dates, supportyear /quarter/month/weekofyear/ dayofyear(dayofmonth/dayofweek) /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  | 
Take out the values of the year, month, day, etc.  | 
var date= new Date("July 21, 1983 01:15:00"); var a=datePart(date,"year");//a=1983  | 
split  | 
Split the string into an array of strings. split(String str, String delim, Object limit);  | 
var str="How are you doing today?"; var b=str.split(" "); The result is How,are,you,doing,today?  | 
split2Array  | 
Split the string into an array of strings.  | 
var a ="How are you"; var b=split2Array(a,2);  | 
formatNumber  | 
Functions can return expressions that are formatted as numbers.  | 
var a =formatNumber(498.8573945,"#,##0.##");Can output: 498.86  | 
toString  | 
You can convert a logical value to a string and return the result.  | 
var b=2.34; var a =toString(b);  | 
substring  | 
Returns a new string that is a substring of this string.  | 
var b=”Hello world”; var a =b.substring(0,3);  | 
sqr  | 
Square the data. sqr(Object val);  | 
var a=sqr(2);//a=4  | 
sqrt  | 
Returns the square root of the given data. sqrt(9);  | 
var a=sqrt(9);//a=3  | 
abs  | 
Returns the absolute value of the given data. abs(-7);  | 
var a=abs(-7);//a=7  | 
debug  | 
Prints information to the log file. debug(Object msg);  | 
debug("msg");  | 
execute  | 
Run a query. Execute (Scriptable script, int type, String path)//Scriptale script is the scope of the script, type is the type of the query  | 
var data=execute(this, Embed, "query1");  | 
preExecute  | 
Pre-compile a query first preExecute(Scriptablescript,inttype,Stringpath,Object allcols)  | 
var a=preExecute(this,SQL,"data",true); var b=executed(a); setData("Table1",b,DATA);  | 
executed  | 
Run a pre-compiled query executed(Object executedID)  | 
var a=preExecute(this,SQL,"data",true); var b=executed(a); setData("Table1",b,DATA);  | 
removeExecuted  | 
Delete pre-compiled queries removeExecuted(Object executedID)  | 
var a=preExecute(this,SQL,"data",true); var b=removeExecuted(a); var c=executed(a); setData("Table1",c,DATA);  | 
join  | 
Connect two data and connect two queries. join(Scriptable scope, int jhint, int jop, Object jleft, Object jright, Object jlkeys, Object jrkeys, Object jlcols, Object jrcols)  | 
For example: join(this, FINAL_JOIN | LEFT_MAIN, LEFT_JOIN, lt, rt, lkeys, rkeys, lcols, rcols);  | 
union  | 
Merge two data networks, merge multiple data networks, and find intersections.union (Scriptable scope, Object ugrids)  | 
Union(this, [a, b]);  | 
columns  | 
Extracting N columns from the data network forms a new data network.columns (Scriptable scope, Object cgrid, Object ccols)  | 
columns(this, query1, [3,1] );//Remove the 3rd and 1st columns in query1 to form a new data network  | 
sort  | 
Sort data network-specific data segments.sort (Scriptable scope, Object sgrid, Object scols, Object sascs)  | 
sort(this, query1, [3,1], [SORT_DESC, SORT_ASC]);//The first column is descending and the first column is ascending.  | 
embed  | 
The array is converted to an embedded query. embed(Object val)  | 
var a=[["编号","2","3"],["姓","wang","yao"]]; var b=embed(a); setData("Table1",b,DATA);  | 
toArray  | 
The columns in the query are converted to arrays. toArray(Object gobj,Object cobj)  | 
var query1=execute(this,SQL, 'coffee3'); var a=toArray(query1,"product"); data=compare("Decaf Espresso",a[0]);  | 
position  | 
Convert longitude and latitude to a long integer for storage. position(Object ox, Object oy)  | 
position(10, 10);  | 
putGlobal  | 
Global constants. putGlobal(String key,Object val)  | 
putGlobal("a",1) var c=a;  | 
toSQLDate  | 
Ordinary date converted to SQL supported timestamp  | 
var a=new Date("January 12,2006 22:19:35"); var b=toSQLDate(a, DType.TIME).toString();  | 
indexOf  | 
Returns the first occurrence of a specified string value in a string  | 
var a="my hello world!" var b=a.indexOf("hello");  | 
substring  | 
Returns a subset of the string at a specified location.  | 
var a = "Hello World"; substring(a, 1, 3);  | 
toDate  | 
Convert background fetch time to another time  | 
var a=param["date"]; var b=toDate(a).toString().substring(0,10);  | 
aggregates  | 
Grouping data results into new data results  | 
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("Table1", b, DATA);  |