六、DDE服务器函数

六、DDE服务器函数

1、GetCommandDDE()

功  能:得到DDE客户应用发送的命令。

语  法:GetCommandDDE ( string )

参  数:string:string类型的变量,用于保存DDE客户应用发送的命令。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果string参数的值为NULL, GetCommandDDE()函数返回NULL。

用  法:当DDE客户应用向DDE服务器应用发送一条命令时,这个动作将触发DDE服务器应用活动窗口的RemoteExec事件,在这个事件的事件处理程序中,可以使用GetCommandDDE()函数得到DDE客户应用发送的命令。

示  例:This excerpt from a script for the RemoteExec event checks to see if the action requested by the DDE client is Open Next Sheet. If it is, the DDE server opens another instance of the sheet DataSheet. If the requested action is Shut Down, the DDE server shuts itself down. Otherwise, it lets the DDE client know the requested action was invalid.

The variables ii_sheetnum and i_DataSheet[ ] are instance variables for the window that responds to the DDE event:

integer ii_sheetnum

DataSheet i_DataSheet[ ]

This script that follows uses the local variable ls_Action to store the command sent by the client application:

string ls_Action

GetCommandDDE(ls_Action)

IF ls_Action = "Open Next Sheet" THEN

ii_sheetnum = ii_sheetnum + 1

OpenSheet(i_DataSheet[ii_sheetnum], w_frame_emp)

ELSEIF ls_Action = "Shut Down" THEN

    HALT CLOSE

ELSE

    RespondRemote(FALSE)

END IF

 

2、GetCommandDDEOrigin()

功  能:确定哪一个DDE客户应用向服务器发送了命令。

语  法:GetCommandDDEOrigin ( applstring )

参  数:applstring:string变量,用于保存发送命令的DDE客户应用的名称。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果applstring参数的值为 NULL,GetCommandDDEOrigin()函数返回NULL。

示  例:This script uses the local variable ls_name to store the name the client application used to identify the server application:

string ls_name

GetCommandDDEOrigin(ls_name)

 

3、GetDataDDE()

功  能:得到DDE客户应用发送的数据。

语  法:GetDataDDE ( string )

参  数:string:string类型变量,用于保存接收到的数据。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL, GetDataDDE()函数返回NULL。

示  例:Assuming that your PowerBuilder DDE client application has established a hot link with row 7, column 15 of an Excel spreadsheet, and that the value in that row and column address has changed from red to green (which triggers the HotLinkAlarm event in your application), this script for the HotLinkAlarm event calls GetDataDDE to store the new value in the variable Str20:

// In the script for a HotLinkAlarm event

string Str20

GetDataDDE(Str20)

 

4、GetDataDDEOrigin()

功  能:确定哪个DDE客户应用发送了数据。

语  法:GetDataDDEOrigin ( applstring, topicstring, itemstring )

参  数:applstring:string类型变量,用于保存客户应用的名称;

topicstring:string类型变量,用于保存主题(比如,在Excel中,主题可以是REGION.XLS);

itemstring:string类型变量,用于保存数据项标识(比如,在Excel中,数据项标识可能是R1C2);

返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL,GetDataDDEOrigin()函数返回NULL。

示  例:This example illustrates how to call GetDataDDEOrigin:

string WhichAppl, WhatTopic, WhatLoc

GetDataDDEOrigin(WhichAppl, WhatTopic, WhatLoc)

 

5、RespondRemote()

功  能:向客户端应用指明最近的命令或数据是否已经接收。

语  法:RespondRemote ( boolean )

参  数:boolean:其值为boolean量的逻辑表达式,TRUE表示接收先前收到的命令或数据,FALSE表示不接收先前收到的命令或数据。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果boolean参数的值为NULL,

RespondRemote()函数返回NULL。

示  例:In a script for the HotLinkAlarm event, these statements tell a remote application named Gateway that its data was successfully received:

String Applname, Topic, Item, Value

GetDataDDEOrigin(Applname, Topic, Item)

IF Applname = "Gateway" THEN

    IF GetDataDDE(Value) = 1 THEN

      RespondRemote(TRUE)

    END IF

END IF

 

6、SetDataDDE()

功  能:向DDE客户应用发送数据。

语  法:SetDataDDE ( string {, applname, topic, item } )

参  数:string:指定要发送到DDE客户应用的数据;

applname:string类型,可选项,指定接收数据的客户应用的DDE名称;

topic:string类型,可选项,指定基础数据组;

item:string类型,可选项,指定基础数据组中的数据项。

返回值:Integer。函数执行成功时返回1,发生错误时返回下述值之一:

-1 -- 函数调用的环境不对;

-2 -- 数据未被接收。

如果任何参数的值为NULL,SetDataDDE()函数返回NULL。

示  例:This statement illustrates how SetDataDDE is used in a script for a RemoteRequest event when another DDE application requests data. The data sent is the text of the SingleLineEdit

sle_Address:

SetDataDDE(sle_Address.Text)

This statement illustrates how the optional arguments are specified:

SetDataDDE(sle_Address.Text, "MYDB", "Employee", "Address")

 

7、StartServerDDE()

功  能:将当前应用设置为DDE服务器。

语  法:StartServerDDE ( { windowname, } applname, topic {, item } )

参  数:windowname:可选项,指定服务器窗口名,缺省值为当前窗口;

applname:当前应用的DDE名称;

topic:string类型,指定DDE客户应用能够引用的基本数据组;

item:由逗号(,)分隔的一个或多个字符串,指定服务器应用支持的数据项。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1,表示当前应用已经设置为DDE服务器。如果任何参数的值为NULL,StartServerDDE()函数返回NULL。

示  例:This statement causes your PowerBuilder application to begin acting as a server. It is known to other DDE applications as MyPBApp; its topic is System, and it supports items called Table1 and Table2:

StartServerDDE(w_emp, "MyPBApp","System", "Table1", "Table2")

 

8、StopServerDDE()

功  能:停止当前应用的DDE服务器功能。执行该函数后,发给该应用的任何DDE客户应用请求都将失败。

语  法:StopServerDDE ( { windowname, } applname, topic )

参  数:windowname:可选项,指定要关闭服务器功能的服务器窗口名,缺省值为当前窗口,如果当前应用有多个服务器窗口,那么必须指定该参数;

applname:当前应用的DDE名称;

topic:string类型,应该与StartServerDDE()中对应参数相同。

返回值:Integer。函数执行成功时返回1,发生错误时返回-1,表示当前应用未曾作为DDE服务器启动。如果任何参数的值为NULL,StopServerDDE()函数返回NULL。

示  例:This statement causes the PowerBuilder application MyPBApp to stop acting as a server:

StopServerDDE(w_emp, "MyPBApp", "System")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值