siebel escript入门——基础知识一

1.检测escript变量是否已定义

var test;
if(typeof test == "undefined");
TheApplication.RaiseErrorText("test is undefined");

2.escript的基本数据类型

escript             javascript
chars               String
float               Number
bool                Boolean
undefined

3.escript的对象数据类型有:

String      
Boolean     
Number      
Array       
Null        
Application     
BLOB        
BlobDescriptor
Buffer      
Buscomp         
BusObject       
CfgItem     
Clib        
CTIData         
CTIService      
Date
Exception       
File        
Math        
PropertySet 
RegExp      
SELib       
Service     
WebApplet

4.使用后需要释放的对象数据

Application    
Buscomp  
BusObject   
CfgItem  
CTIService   
CTIData 
PropertySet     
Service     
WebApplet

5.如何判断变量是否能转换成数字

var Test = "a string";
if(isNaN(parseInt(Test)));
TheApplication.RaiseErrorText("Test is Not a Number");

6.声明强类型变量——在变量后加上冒号,然后加上数据类型名称

var a : Date = new Date();
var BO :BusObject;
var BC :Buscomp;

7.escript中的数字运算符

符号              目的              说明
=               赋值              将值赋给某个变量
+               相加              两个数相加
-               相减              一个数减去另外一个数
*               相乘              两个数相乘
/               相除              一个数除以另外一个数
%               求模              返回相除后的余数
+=              加法              自身加上其他数
-=              减法              自身减去其他数
*=              乘法              自身乘以其他数
/=              除法              自身除以其他数
%=              求模              自身对其他数求模
++              自动加1
--              自动减1

8.位运算符

操作符               说明                举例
<<                  左移
<<=
>>                  右移
>>=
>>>                 无符号右移
>>>=
&                   与
&=
|                   或
|=
^                   异或
^=
~                   非

9.逻辑运算符

符号                  目的              说明
!                   逻辑非
&&                  逻辑与
||                  逻辑或
==                  相等
!=                  不相等
<                   小于
>                   大于
<=                  小于等于
>=                  大于等于

10.escript中比较弱类型变量时比较的是值,但是比较强类型变量时比较的却是变量名称

//返回not equal
function foo() {
    var oStr1:String = new String("aa");
    var oStr2:String = new String("aa");
    if(oStr1==oStr2)
        TheApplication.RaiseErrorText("equal");
    else
        TheApplication.RaiseErrorText("not equal");
}
//返回not equal,虽然不是强类型的比较,但是因为String是对象数据类型
function foo() {
    var oStr1 = new String("aa");
    var oStr2 = new String("aa");
    if(oStr1==oStr2)
        TheApplication.RaiseErrorText("equal");
    else
        TheApplication.RaiseErrorText("not equal");
}

11.确保比较变量时总是能比较值

//方法1:使用valueOf ()
function foo (){
    var oStr1 = new String("aa");
    var oStr2 = new String("aa");
    if (oStr1.valueOf()==oStr2.valueOf())
        TheApplication().RaiseErrorText("equal");
    else
        TheApplication().RaiseErrorText("no equal");
}
//方法2:使用原生(primitive)数据类型
function foo() {
    var oStr1:chars="aa";
    var oStr2:chars="aa";
    if(oStr1==oStr2)
        TheApplication.RaiseErrorText("equal");
    else
        TheApplication.RaiseErrorText("not equal");
}

12.typeof运算符,返回值是字符串,可能是
undefined/boolean/string/object/number/function/buffer

var result=typeof variable;
var result=typeof(variable);

13.条件运算符

expression ? true : false;
foo=(5<6)?100?200;  //foo=100

14.字符串连接符:+

var proverb = "A rolling stone" + "gathers no moss.";
var newString = 4 + "get it";  //4get it
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值