Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DDE between two Tk app's

Status
Not open for further replies.

Bong

Programmer
Dec 22, 1999
2,063
0
0
US
I have a Tk app that contains little more than a text widget:
Code:
package require dde
dde servername receiving
pack [frame .f1] -side top
pack [text .f1.t1] -side top

Then I have another Tk app that is supposed to display a string (tagged) in the first app's text widget:
Code:
package require dde
dde servername sending
foreach f {1 2 3} {pack [frame .$f] -side left}
pack [label .1.l1 -text "string to send"] -side top
pack [entry .2.e1 -textvariable sndstr] -side top
pack [button .3.b1 -text send -command {set counter [ddeSend $counter $sndstr]}
set counter 1
set sndstr "data from sender"
proc ddeSend {counter sndstr} {
  set target .f1.t1
  dde execute TclEval receiving {$target insert end $sndstr\n $counter}
  incr counter
  return $counter
}

When I run the receiving app and the sending app, nothing happens when I press the button. However, if I show the console on the sending app and type in the exact same comand: $target insert end $sndstr\n $counter, after making sure the variables are set, the string is properly displayed in the target text widget.

Can anyone see why the GUI command isn't working?

Bob Rashkin
rrashkin@csc.com
 
I got it to work. It was the old "delayed substitution" problem. It works if the 'send' statement is not delayed but the string is:
dde execute TclEval receiving [red]"[/red]$target insert end [red]{[/red]$sndstr\n[red]}[/red] $counter[red]"[/red]

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top