Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tck/Tk and C

112 views
Skip to first unread message

Marc Hofmann

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
I don't like the way Tcl/Tk is communicating with C-programs. I want to
use Tcl/Tk as a visualisation-tool, but
the C-program has to be a 'stand-alone'-program, that means it should
also run without Tcl/Tk. I guess I have
to create pipes between the C-program and the Tcl-script and send the
data to the script. Has anybody experience
with that approach ? Perhaps an example-programm and script would help
me .....

Thank you
Marc


John Brockmeyer

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
I am having problems loading and running the printer extension stuff in
WIN-98.
the main tcl library is at
c:\Program Files\tcl\lib,
and the printer files (both printer.dll and pkgindex.tcl) are in the
c:\Program Files\tcl\lib\tcl8.0\printer directory.

in wish, when I say
% package require printer
i get
0.7.0.1
which is expected

but when I do

%printer attr

I get

error while autoloading "printer": couldn't load file
"C:\PROGRA~1\TCL\lib\tcl8.0\printer\printer.dll": invalid argument

Any suggestions? I need an immediate answer for some software I am
writing to prove that tcl is just as useful as Visual Basic in the
Windows environment

Thank You

John Brockmeyer
j...@lobo.net


Chang Li

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
John Brockmeyer <j...@lobo.net> writes:

Hi John,

You find a Tcl bug in Win95 again.

Notice you install Tcl in the C:\Program Files\ directory.
The trouble is the space directory for the library "Program Files".
Reinstall your tcl in the directory without the space.

Best,

Chang

Andreas Kupries

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to

Here is a small example demonstrating the usage of the
'fileevent' command to transfer input coming from a
file/socket/pipe (script) into a text widget (*).


The 3 parts are:

1) fe-driver

A tcl script writing a file given on its commandline
to stdout. A delay is executed after each character
to make it slower, enabling the user to follow whole
process.

Buffering of stdout is switched off to enable the
transfer of single characters. line buffering would
occur else.

2) fe

The main script. It reads from a pipe created with
'open' and displays the read data in the text widget.
fileevent is used to handle input as it comes in, without
blocking the application.

3) fe-exam.sh
A simple shell script calling the above with proper
arguments.

The example assumes that tclsh, wish reside in /usr/local/bin.

-------------------------------------------------------------------------------
#!/usr/local/bin/tclsh
# generate characters and send them to stdout.
# use after to make it slower for demonstration purposes

set time [lindex $argv 1]
set data [exec cat [lindex $argv 0]]
set data [split $data {}]

fconfigure stdout -buffering none

foreach x $data {
puts -nonewline $x
after $time
}
-------------------------------------------------------------------------------
#!/usr/local/bin/wish
# fileevent example
# (reading the output of an external command into a text widget)
# no luxuries (like scrollbars)

set command [lindex $argv 0]

set f [open "|$command" r]
fconfigure $f -blocking 0

fileevent $f readable [list handleInput $f]

text .t -bd 3 -relief sunken -bg yellow -fg red -width 80 -height 30
pack .t -side top -fill both -expand 1

proc handleInput {f} {
# - delete handler if input was exhausted.
if {[eof $f]} {
fileevent $f readable {}
close $f
return
}

set data [read $f]

if {[string length $data] > 0} {
.t insert end $data
}
}
-------------------------------------------------------------------------------
#!/bin/sh
fe 'fe-driver fe 1'
-------------------------------------------------------------------------------


(*) This example uses a pipe. I have another for sockets. Just mail
and ask for it.
--
Sincerely,
Andreas Kupries <a.ku...@westend.com>
<http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------

John Brockmeyer

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
On Mon, 13 Jul 1998, John Brockmeyer wrote:

> I am having problems loading and running the printer extension stuff in
> WIN-98.
> the main tcl library is at
> c:\Program Files\tcl\lib,
> and the printer files (both printer.dll and pkgindex.tcl) are in the
> c:\Program Files\tcl\lib\tcl8.0\printer directory.
>
> in wish, when I say
> % package require printer
> i get
> 0.7.0.1
> which is expected
>
> but when I do
>
> %printer attr
>
> I get
>
> error while autoloading "printer": couldn't load file
> "C:\PROGRA~1\TCL\lib\tcl8.0\printer\printer.dll": invalid argument
>
>

Please excuse me. I paniced too early.
It needed cw3220.dll, which you can get off the net.
Now things sort of work.

lvi...@cas.org

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to

According to Marc Hofmann <h...@mmk.e-technik.tu-muenchen.de>:
:I don't like the way Tcl/Tk is communicating with C-programs. I want to
Huh? Tcl/Tk isn't communicating with C programs unless you
(or some other application developer) programed it to.

And so if you don't like the way your specific application works,
pat yourself on your shoulder and let you know you don't like what you coded.


:the C-program has to be a 'stand-alone'-program, that means it should

Well, no, it doesn't _have_ to be a stand alone program. You could
use one of the other variations - like using SWIG or jWrap to
turn your modules into Tcl commands.

:also run without Tcl/Tk. I guess I have


:to create pipes between the C-program and the Tcl-script and send the

No, you could change the C program to use sockets, shared memory,
the Tk send command, etc. Lots of IPC mechanisms.

In fact, I think there is a member of this usenet group who is
working on a high level document touching on some of the
alternatives. Alex, are you back from holiday yet?

:data to the script. Has anybody experience


:with that approach ? Perhaps an example-programm and script would help
:me .....

Lots of folk - in fact, some nice examples appear in the expect
distribution - see <URL:http://www.teraform.com/%7Elvirden/tcl-faq/>
for pointers to Expect.

--
<URL:mailto:lvi...@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.

Alexandre Ferrieux

unread,
Jul 15, 1998, 3:00:00 AM7/15/98
to
lvi...@cas.org wrote:
>
> According to Marc Hofmann <h...@mmk.e-technik.tu-muenchen.de>:
> :I don't like the way Tcl/Tk is communicating with C-programs. I want to
>
> In fact, I think there is a member of this usenet group who is
> working on a high level document touching on some of the
> alternatives. Alex, are you back from holiday yet?

Thanks Larry for this introduction !
In a few days, there'll be an URL ;-)

So Marc, if you can way that long, stay tuned !

-Alex

0 new messages