duzers Posted April 21, 2010 Share Posted April 21, 2010 (edited) I wrote DDE Client that gets the number from the server DDE. Unfortunately, I have a problem because it stop working after given time. When I use Sleep(20) its returns empty string after about 8 minutes, or with sleep(5) after 3 minutes. This code is designed to analyze the data collected for 8 hours, as soon as possible. I know that the problem is server side, but maybe my code is badly written and there are commands that will solve the problem of overflow server. Mayby I use wrong loop? Thank you for your help. #include <DDEML.au3> #include <DDEMLClient.au3> sleep(2000) _DdeInitialize("OnDDE_", $APPCLASS_STANDARD) $hszService = _DdeCreateStringHandle("Program") $hszTopic = _DdeCreateStringHandle("DDE") $hConvSrv = _DdeConnect($hszService, $hszTopic) $hszItem = _DdeCreateStringHandle("Numbers") $d = TimerInit() while 1 sleep (20) $res2 = _DdeClientTransaction($XTYP_REQUEST, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) $res_b2 = _DdeGetDataAsString($res2) ConsoleWrite("number: " & $res_b2 & round(timerDiff($d)/1000) &@CRLF) wend Edited April 21, 2010 by duzers Link to comment Share on other sites More sharing options...
doudou Posted April 21, 2010 Author Share Posted April 21, 2010 I wrote DDE Client that gets the number from the server DDE. Unfortunately, I have a problem because it stop working after given time. When I use Sleep(20) its returns empty string after about 8 minutes, or with sleep(5) after 3 minutes. This code is designed to analyze the data collected for 8 hours, as soon as possible. I know that the problem is server side, but maybe my code is badly written and there are commands that will solve the problem of overflow server. Mayby I use wrong loop? Thank you for your help. #include <DDEML.au3> #include <DDEMLClient.au3> sleep(2000) _DdeInitialize("OnDDE_", $APPCLASS_STANDARD) $hszService = _DdeCreateStringHandle("Program") $hszTopic = _DdeCreateStringHandle("DDE") $hConvSrv = _DdeConnect($hszService, $hszTopic) $hszItem = _DdeCreateStringHandle("Numbers") $d = TimerInit() while 1 sleep (20) $res2 = _DdeClientTransaction($XTYP_REQUEST, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) $res_b2 = _DdeGetDataAsString($res2) ConsoleWrite("number: " & $res_b2 & round(timerDiff($d)/1000) &@CRLF) wend If you don't answer to callbacks in your client you probably should initialize it with: _DdeInitialize("", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS)) Most servers would only submit requested data associated with a specific topic if it isn't changed and try to notify the clients via callbacks otherwise. Polling a server with the same request every 20 or even every 5 ms is a bad idea too - if I was the server I'd assume a DOS attack and stop responding, not to speak about 80% processor load you are generating with your loop. If you expect frequent modifications within a specific topic the best solution would be to establish a DDE advise loop where the server notifies clients about changes automatically. UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
duzers Posted April 22, 2010 Share Posted April 22, 2010 Thx, but Your initialize not work. I use in the loop _DdeFreeDataHandle($res2)(write about use of this instruction) and work very well all time.With my processor load is not bad - after and now it's about 2%, even when I use sleep (1).If you expect frequent modifications within a specific topic the best solution would be to establish a DDE advise loop where the server notifies clients about changes automatically.How I do this (give examples)? Which commands I should use or pay attention? Link to comment Share on other sites More sharing options...
doudou Posted April 22, 2010 Author Share Posted April 22, 2010 Thx, but Your initialize not work.But sure, it does. Unless you need callbacks, in which case you didn't post all relevant code.I use in the loop _DdeFreeDataHandle($res2)(write about use of this instruction) and work very well all time.This is again all about your tight loop: normally you don't need to _DdeFreeDataHandle() (s. here), the fact that calling this fixes the issue just shows that your system runs out of resources and gets no chance to free them.With my processor load is not bad - after and now it's about 2%, even when I use sleep (1).This is only because the server is slow enough, when I use your loop with my SampleDDEServer I get 80%. Believe me, when I say: this is simply a bad idea. Sleep(1) or Sleep(20) makes no difference in practice since the scheduler may need up to 30 ms to switch between execution contexts and anything below 100 ms in the loop is definitely to tight while bringing virtually no performance advantage.How I do this (give examples)? Which commands I should use or pay attention?Take a look at XTYP_ADVDATA transaction. Basically it is the same as XTYP_REQEST except for the server sends data only when the assosiated item has changed and here you will need callbacks on the client side like OnDDE_AdvData to receive the data. UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
doudou Posted April 23, 2010 Author Share Posted April 23, 2010 Last version had couple of bugs. Fixed them in 1.5.4.I wonder, who's still downloading v. 1.2? Are there so many people with AutoIt 3.1.x out there? UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
Alisonr Posted August 4, 2010 Share Posted August 4, 2010 I have an application (Trading system for Market Shares) that works like a DDE server for excel. On this application there is a wizard to create links DDE to excel like this one "=BIDS|COTC!'PETR4,LAST'" I just need to copy and past it to any cell in excel and it will bing the last price of a company share. So, looking to "=BIDS|COTC!'PETR4,LAST'", it seems: BIDS is DDE server name COTC is a type of data (shares quotation) PETR4 is a (Company share code) LAST is the last price Can someone tell me the syntax to get this DDE value and put it into a AutoIt variable ? Thanks in Advanced. Link to comment Share on other sites More sharing options...
doudou Posted August 4, 2010 Author Share Posted August 4, 2010 I have an application (Trading system for Market Shares) that works like a DDE server for excel. On this application there is a wizard to create links DDE to excel like this one "=BIDS|COTC!'PETR4,LAST'" I just need to copy and past it to any cell in excel and it will bing the last price of a company share. So, looking to "=BIDS|COTC!'PETR4,LAST'", it seems: BIDS is DDE server name COTC is a type of data (shares quotation) PETR4 is a (Company share code) LAST is the last price Can someone tell me the syntax to get this DDE value and put it into a AutoIt variable ? I am not familiar with the crude Excel DDE syntax but it looks like it performs a DDE request, so in the simplest case the AutoIt equivalent would be: #include <DDEML.au3> #include <DDEMLClient.au3> Dim $strData = _DDEMLClient_RequestString("BIDS", "COTC", "PETR4,LAST") MsgBox(0, "PETR4 Price", $strData) Please note: DDE is a very loose protocol, except for very few rules it leaves all details about conversation to participants. If the example above doesn't work, you will have to consult the documentation of the DDE server and try out different methods and paramters. UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
tts Posted September 12, 2010 Share Posted September 12, 2010 (edited) have "Advise" mode? can requests "Advise" mode's Sample? Thanks~ Edited September 12, 2010 by tts Link to comment Share on other sites More sharing options...
bile Posted September 14, 2010 Share Posted September 14, 2010 (edited) expandcollapse popuplogga($log,"Initializing DDE.....") ; logga is a function I use to create a log for my application, just ignore that $return=_DdeInitialize("OnDDE_", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS)) if $return=0 then logga($log,"OK") Else logga($log,"DDEinitialize ERROR:"&$return) EndIf $hszService = _DdeCreateStringHandle("MYSERVER") $hszTopic = _DdeCreateStringHandle("MYTOPIC") $hConvSrv = _DdeConnect($hszService, $hszTopic) if $hconvSrv=0 Then logga($log,"DDEConnect ERROR") Else logga($log,"Connected") endif ;-----------------------------------intializing ADVISE LOOP--------------------------------------------- $hszItem = _DdeCreateStringHandle("MYITEM") $res = _DdeClientTransaction($XTYP_ADVSTART+$XTYPF_ACKREQ, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) ; ;...................... ;----------------------------------------------------------------------------------------------------------------- ; Func ON_DDE_AdvData ; ; $hSz1 and $hSz2 are strings containing the topic and item ; $uFmt ???? I don't know...my server sends 1 but can't figure out the meaning ; $hData is a handle to data, I use it calling _DdeGetDataAsString and it works fine ; $hConv handle to the DDE conversation ;----------------------------------------------------------------------------------------------------------------- Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) ; DO SOMETHING WITH DATA endfunchave "Advise" mode? can requests "Advise" mode's Sample? Thanks~ Hi tts...and thanks to doudou for this excellent job. I just wrote a simple client script to receive data from a DDE server (stocks quote...) in advise mode, hope it is useful. I still can't figure out the meaning of $uFmt passed to the OnDDE_AdvData function...any hints from someone? EDIT: OK found, It's the clipboard format :-b Edited September 14, 2010 by bile Link to comment Share on other sites More sharing options...
tts Posted September 24, 2010 Share Posted September 24, 2010 thanks~ but I dont know this: Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) ; DO SOMETHING WITH DATA endfunc how to make it callback? Link to comment Share on other sites More sharing options...
bile Posted September 27, 2010 Share Posted September 27, 2010 thanks~ but I dont know this: Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) ; DO SOMETHING WITH DATA endfunc how to make it callback? It is defined as the callback function for the event "AdvData" by the previous call to DDEInitialize. Remember to make your function return the value $DDE_FACK. Link to comment Share on other sites More sharing options...
tts Posted September 28, 2010 Share Posted September 28, 2010 It is defined as the callback function for the event "AdvData" by the previous call to DDEInitialize.Remember to make your function return the value $DDE_FACK.thank you very much~i got it! Link to comment Share on other sites More sharing options...
ValeryVal Posted September 28, 2010 Share Posted September 28, 2010 Thank you for DDEML UDF. This Avenue Console could be an example of ArcView DDE server usage from AutoIt (tested for v.3.2). Enjoy, ArcView.au3 The point of world view Link to comment Share on other sites More sharing options...
mailro Posted March 18, 2011 Share Posted March 18, 2011 thank you very much~i got it!I can't understand it. How do I display the data? Link to comment Share on other sites More sharing options...
mailro Posted March 18, 2011 Share Posted March 18, 2011 I can't understand it. How do I display the data?This is how excell is getting the data from the sourceTask:0x11e4 Time:300752375 Callback: Type=Connect, fmt=0x0("?"), hConv=0x0, hsz1=0xc000("ES") hsz2=0xc001("Console"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x1Task:0x11e4 Time:300752375 Callback: Type=Connect_confirm, fmt=0x0("?"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc000("Console"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752437 Callback: Type=Advstart, fmt=0xc370("XlTable"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc001("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752437 Callback: Type=Advstart, fmt=0xc005("Binary"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc000("StdDocumentName"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752453 Callback: Type=Advstart, fmt=0xc33a("Biff8"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc001("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752453 Callback: Type=Advstart, fmt=0xc377("Biff4"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc000("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752468 Callback: Type=Advstart, fmt=0xc34b("Biff3"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc001("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752468 Callback: Type=Advstart, fmt=0x4("CF_SYLK"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc000("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752468 Callback: Type=Advstart, fmt=0xc339("Wk1"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc001("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752484 Callback: Type=Advstart, fmt=0xc364("Csv"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc000("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0Task:0x11e4 Time:300752484 Callback: Type=Advstart, fmt=0xd("CF_UNICODETEXT"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc001("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x0"Exch_Time"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x1Task:0x11e4 Time:300752484 Callback: Type=Advstart, fmt=0x1("CF_TEXT"), hConv=0x59000d00, hsz1=0xc001("ES") hsz2=0xc002("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x1Task:0x11e4 Time:300752500 Callback: Type=Request, fmt=0x1("CF_TEXT"), hConv=0x59000d00, hsz1=0xc000("ES") hsz2=0xc002("Last"), hData=0x0, dwData1=0x0, dwData2=0x0 return=0x5f001300 Output data= ... Link to comment Share on other sites More sharing options...
bile Posted March 19, 2011 Share Posted March 19, 2011 (edited) I can't understand it. How do I display the data? When the callback function is called, requested data are in $hData. You can get data as string using _DdeGetDataAsString() Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) local $stringdata ; $hsz2 is a string containing the topic/item you requested (at least in my case) $stringdata=_DdeGetDataAsString($hData) ;......DO SOMETHING WITH $stringdata EndFunc Depending on the DDE server you are connecting to, I suppose _DdeGetDataAsString() may not be suitable... Edited March 19, 2011 by bile Link to comment Share on other sites More sharing options...
mailro Posted March 20, 2011 Share Posted March 20, 2011 When the callback function is called, requested data are in $hData. You can get data as string using _DdeGetDataAsString() Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) local $stringdata ; $hsz2 is a string containing the topic/item you requested (at least in my case) $stringdata=_DdeGetDataAsString($hData) ;......DO SOMETHING WITH $stringdata EndFunc Depending on the DDE server you are connecting to, I suppose _DdeGetDataAsString() may not be suitable... Ok. Here is the code complete and working expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <DDEML.au3> #include <DDEMLClient.au3> OnAutoItExitRegister("CleanExit") _DdeInitialize("OnDDE_", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS)) Global $frmMain = GUICreate("Sample DDE Client", 560, 105, -1, -1, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) Global $lblOut = GUICtrlCreateLabel("Nothing yet", 11, 60, 333, 31, BitOR($SS_RIGHT,$SS_NOPREFIX)) GUISetState(@SW_SHOW) $hszService = _DdeCreateStringHandle("Service") $hszTopic = _DdeCreateStringHandle("Topic") $hConvSrv = _DdeConnect($hszService, $hszTopic) $hszItem = _DdeCreateStringHandle("Item") $res = _DdeClientTransaction($XTYP_ADVSTART+$XTYPF_ACKREQ, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) OnDDE_AdvData("","","","","") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) local $stringdata ; $hsz2 is a string containing the topic/item you requested (at least in my case) $stringdata=_DdeGetDataAsString($hData) ;......DO SOMETHING WITH $stringdata GUICtrlSetData($lblOut, "Requested data:" & $stringdata) EndFunc Func CleanExit() If 0 <> $hConvSrv Then _DdeClientTransaction($XTYP_ADVSTOP, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) _DdeFreeStringHandle($hszService) _DdeFreeStringHandle($hszTopic) _DdeFreeStringHandle($hszItem) _DdeDisconnect($hConvSrv) $hConvSrv = 0 EndIf _DdeUninitialize() ConsoleWrite("CleanExit" & @CRLF) EndFunc It is working but what I don't understand is that Either I call it this way OnDDE_AdvData("","","","","") either OnDDE_AdvData("Servie","Topic","","Item",$hConvSrv) I am getting the same result!!! Link to comment Share on other sites More sharing options...
mailro Posted March 20, 2011 Share Posted March 20, 2011 I have come to this working code below. The problem that I have is that when I have more than 2 items I can't catch the right callback. I am always getting the last one. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <DDEML.au3> #include <DDEMLClient.au3> OnAutoItExitRegister("CleanExit") Global $hConvSrv = 0 $return=_DdeInitialize("OnDDE_", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS)) If $return <> 0 Then MsgBox(0, "Error", "Failed to Initialize") Global $frmMain = GUICreate("Sample DDE Client", 560, 105, -1, -1, BitOR($WS_SYSMENU, $WS_DLGFRAME, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) Global $lblOut = GUICtrlCreateLabel("Nothing yet", 11, 60, 333, 31, BitOR($SS_RIGHT, $SS_NOPREFIX)) Global $lblError = GUICtrlCreateLabel("Errors: ", 450, 0, 333, 31, BitOR($SS_RIGHT, $SS_NOPREFIX)) GUISetState(@SW_SHOW) main() OnDDE_AdvData("", "", "", "", "") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $error = _DdeGetLastError() GUICtrlSetData($lblError, "Error: " & $error) WEnd Func main() $hszService = _DdeCreateStringHandle("Service") $hszTopic = _DdeCreateStringHandle("Topic") $hConvSrv = _DdeConnect($hszService, $hszTopic) While $hConvSrv = 0 Sleep(2000) $hConvSrv = _DdeConnect($hszService, $hszTopic) WEnd _DdeFreeStringHandle($hszService) _DdeFreeStringHandle($hszTopic) $hszItem1 = _DdeCreateStringHandle("Item1") $res1 = _DdeClientTransaction($XTYP_ADVSTART + $XTYPF_ACKREQ, $hConvSrv, 0, 10000, $hszItem1, $CF_TEXT) EndFunc ;==>main Func OnDDE_AdvData($hSsz1, $hSsz2, $uFmt, $hData, $hConv) Local $stringdata $stringdata = _DdeGetDataAsString($hData) GUICtrlSetData($lblOut, "Requested data: " & $hSsz1 & ": " & $hSsz2 & ": " & $stringdata) EndFunc ;==>OnDDE_AdvData Func CleanExit() If 0 <> $hConvSrv Then _DdeDisconnect($hConvSrv) $hConvSrv = 0 EndIf _DdeUninitialize() ConsoleWrite("CleanExit" & @CRLF) EndFunc ;==>CleanExit When I add: $hszItem2 = _DdeCreateStringHandle("Item2") $res2 = _DdeClientTransaction($XTYP_ADVSTART + $XTYPF_ACKREQ, $hConvSrv, 0, 10000, $hszItem2, $CF_TEXT) I don't know how to make the OnDDE_AdvData to report the first one. It always reports the last one Link to comment Share on other sites More sharing options...
doudou Posted March 21, 2011 Author Share Posted March 21, 2011 (edited) The second variant of your code looks completely broken, the first one below may be better point to start (anyway you said yourself, it's working). Ok. Here is the code complete and working expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <DDEML.au3> #include <DDEMLClient.au3> OnAutoItExitRegister("CleanExit") _DdeInitialize("OnDDE_", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS)) Global $frmMain = GUICreate("Sample DDE Client", 560, 105, -1, -1, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) Global $lblOut = GUICtrlCreateLabel("Nothing yet", 11, 60, 333, 31, BitOR($SS_RIGHT,$SS_NOPREFIX)) GUISetState(@SW_SHOW) $hszService = _DdeCreateStringHandle("Service") $hszTopic = _DdeCreateStringHandle("Topic") $hConvSrv = _DdeConnect($hszService, $hszTopic) $hszItem = _DdeCreateStringHandle("Item") $res = _DdeClientTransaction($XTYP_ADVSTART+$XTYPF_ACKREQ, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) OnDDE_AdvData("","","","","") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OnDDE_AdvData($hSsz1,$hSsz2,$uFmt,$hData,$hConv) local $stringdata ; $hsz2 is a string containing the topic/item you requested (at least in my case) $stringdata=_DdeGetDataAsString($hData) ;......DO SOMETHING WITH $stringdata GUICtrlSetData($lblOut, "Requested data:" & $stringdata) EndFunc Func CleanExit() If 0 <> $hConvSrv Then _DdeClientTransaction($XTYP_ADVSTOP, $hConvSrv, 0, 10000, $hszItem, $CF_TEXT) _DdeFreeStringHandle($hszService) _DdeFreeStringHandle($hszTopic) _DdeFreeStringHandle($hszItem) _DdeDisconnect($hConvSrv) $hConvSrv = 0 EndIf _DdeUninitialize() ConsoleWrite("CleanExit" & @CRLF) EndFunc If you wish to receive callbacks from your server in an advise loop you must not disable them by passing $CBF_SKIP_ALLNOTIFICATIONS in _DdeInitialize(), please consult MSDN for possible values and their meanings. Further, it's been said here already: return $DDE_FACK (s. MSDN on DdeCallback) from OnDDE_AdvData() otherwise server would consider callback failed. It is working but what I don't understand is that Either I call it this way OnDDE_AdvData("","","","","") either OnDDE_AdvData("Servie","Topic","","Item",$hConvSrv) I am getting the same result!!! There's absolutely no point for these calls (especially pointless: OnDDE_AdvData("","","","","")) being placed in client code, OnDDE_AdvData() is a callback function and is to be called by DDEML library and this only. Side note (looking at your 2nd post): don't free $hszService and $hszTopic before you are done with the DDE conversation, the same is valid for $hszItem as long as your client is exchanging data associated with it (i.e. keep it until the advise loop ends). Edited March 21, 2011 by doudou UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
JCarson Posted March 21, 2011 Share Posted March 21, 2011 Out of morbid curiosity, has anyone attempted to connect to and OPC server using this code? Thanks, Carson Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now