六、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")
總結
以上是生活随笔為你收集整理的六、DDE服务器函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 0x80070005,PHPII
- 下一篇: weka,FP,priori