常识(1)- TriggerEvent()/Event()/PostEvent()有什么不同

TriggerEvent()/Event()/PostEvent()有什么不同

在PB中经常要从一个事件中调用另外一个事件,常用的就是这几个函数

event把被调用事件放在最后面处理,可以带参数,也可以返回值,dynamic event()是其经典用法

注:Dynamic表示编译时指定事件可以不存在,系统把返回值类型检查推迟,到应用程序运行时进行。

triggerEvent触发指定对象的指定事件,是在事件队列的当前位置插入指定的事件,并且立即执行该事件中的脚本,它只能返回1,-1 或者空,带了long,word也比较麻烦

PostEvent在事件队列最后追加指定的事件,不是立即执行

-----

In PowerBuilder, there are several types of events.
System events with an ID:
User actions or other system messages or a call in your scripts

System events without an ID:

User-defined events with an ID:User actions or other system messages or a call in your scripts

User-defined events without an ID:A call in your scripts

-----
objectname.TriggerEvent ( event {, word, long } )

Triggers an event associated with the specified object, which executes the script for that event immediately.

Return value
Integer.
Returns 1 if it is successful and the event script runs and -1 if the event is not a valid event for objectname, or no script
exists for the event in  objectname. If any argument's value is null, TriggerEvent returns null.

Usage
If you specify the name of an event instead of a value of the TrigEvent enumerated datatype, enclose the name in double
quotation marks.

-----
objectname.PostEvent ( event, { word, long } )

Adds an event to the end of the event queue of an object.

Return value
Boolean.
Returns true if it is successful and false if the event is not a valid event for objectnameobjectname. Also returns true if
no script exists for the event in objectname. If any argument's value is null, PostEvent returns null.

Usage
You cannot post events to the event queue for an application object. Use TriggerEvent instead.

PowerBuilder messages or a call in your scripts
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值