Retrieve data with DDE in R using tcltk2 library
Asked Answered
T

1

6

Connecting Excel with 'ABC' throught Excel works, connecting R with Excel by DDE works also, but how to connect R with 'ABC' application ?

I have application providing DDE interface, from Excel I could retrieve value from it with this DDE reference :

='ABC'|DDE!_nazwa_value

from R I've tried to use tcltk2 library, as follows :

tcltk2::tk2dde.request(service="ABC", topic="DDE", item="_nazwa_value")

but error occurs :

Error in structure(.External(.C_dotTcl, ...), class = "tclObj") : 
  [tcl] remote server cannot handle this command.

[1] "Error in structure(.External(.C_dotTcl, ...), class = \"tclObj\") : \n  [tcl] remote server cannot handle this command.\n\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in structure(.External(.C_dotTcl, ...), class = "tclObj"): [tcl] remote server cannot handle this command.

I'm only trying to use tcltk dde functions to retrieve data from application, I think that item part of my tk2dde.request is wrong, but I've tried various modification (without _ for example), do you know any clues or resources for solving this problem ?

EDIT

something is wrong I don't see ABC server nor DDE topic on server-topic list : tk2dde.services() but Excel can still connect and retrieve value using ='ABC'|DDE!_nazwa_value, DDE Query also do not see it

Tui answered 9/9, 2018 at 16:24 Comment(14)
Would making item be _nazwa_value (without {…}) work? I'm totally on the wrong platform to check…Aaron
@Donal Fellows good try, but error is the same as above, mayby I should consider issues like registering DDE server, but Excel client works perfectly well so registering server seems to be not the issue and I could also make workaround and get data to Excel from 1ABS1 application and next from Excel to R with request tcltk2::tk2dde.request("Excel", "Data", "R1C1:R25C25") and it works perfectly wellTui
Why the curly braces around "_nazwa_value"?Pneumodynamics
Who have marked my question as favorite ?Tui
I don't think StackOverflow allows users to know who marks questions as favourite, but maybe that person wants to find the solution to your problem too.Isadora
Have you tried using the Tcl dde package directly, package req dde; dde request ...?Boyle
@Boyle there is no dde package at CRANTui
I am referring to the Tcl package dde, that should come with windows builds of Tcl (and so with the Tcl bundle coming with R). What gives (untested):.Tcl("package req dde")?Boyle
@Boyle it gives '<Tcl> 1.4.0'Tui
So, assemble and send your request in Tcl, for a try: .Tcl("package req dde; dde request ABS DDE _nazwa_value")Boyle
Is your server name DDE? From the documentation it looks like topic should be the server name.Ptarmigan
Try the cmd line utility ddecmd. shell("ddecmd request -s ABC -t DDE -i _nazwa_value", intern = TRUE) . chrisoldwood.com/win32/ddecmd/ddecmd.htmlAintab
One other thing to try would be to try tcltk2 from both 64 bit R and 32 bit R versions.Aintab
@Ptarmigan by Ive used 'DDE' as server name : topic="DDE" is it proper - I don't know, how to list server names ? DDESpy don't show everythingTui
P
2

You can read in the article about DDE in tcl/tk wiki:

(Talking about using Internet Explorer) ... All of the above experiments should "work" reliably, in that, from the user perspective, IE indeed acts as described. However, back in the Tcl process, [dde] typically throws a "remote server cannot handle this command" exception. That's because, in KBK's analysis, DDE gives no "way to distinguish 'result expected, but the server failed to provide it' from 'no result is expected'." The only way not to receive a DMLERR_NOTPROCESSED is to invoke "dde exec -async ..."

Note: i tried tcl examples of DDE using Excel + "request" and i got the same error as you: "remote server cannot handle this command".

Saludos!,

Pneumodynamics answered 20/9, 2018 at 2:24 Comment(4)
but connecting with those application with Excel through DDE works, connection from R to Excel by DDe works also, I simply don't know how to connect R directly with 'ABC' applicationTui
You could connect from R to Excel with tcltk2?. If yes, what "parameters" you've used?Pneumodynamics
tk2dde.request("Excel", "Sheet1", "R1C1:R101C25") - simple request which doesn't contain name of fileTui
request : tk2dde.request("Excel", "{[filename.xlsm]Data}", "R1C1:R1C1") also worksTui

© 2022 - 2024 — McMap. All rights reserved.