f



How to use tcl to write a GUI to control a C program

I writed a programe (using C)  to control two objects:
keyboard A-------to make the small object rotate
keyboard Y-------to make the large object rotate

Now,
I want to write a *graph user interface* using Tcl to control the objects.It
should be combined with the C code.
how can I do it?

this is the C code section:

#include <gl/glut.h>
#include <stdlib.h>
#include <stdio.h>
static int year=0,day=0,month=0;
void init(void)
{
 glClearColor(0.0,0.0,0.0,0.0);
 glShadeModel(GL_FLAT);
}
void display(void)
{
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3f(0.0,1.0,0);


 glPushMatrix();
 glRotatef((GLfloat)month,0.0,1.0,0.0);
glutWireSphere(1.0,20,16);//draw sun
 glPopMatrix();
 glPushMatrix();
 glRotatef((GLfloat)year,0.0,1.0,0.0);
 glTranslatef(2.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
 glColor3f(1.0,1.0,0);
 glutWireSphere(0.2,10,8);//draw planet
 glPopMatrix();
 glutSwapBuffers();
}
void reshape(int w,int h)
{
 glViewport(0,0,(GLsizei) w,(GLsizei) h);
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluPerspective(60.0,(GLfloat) w/(GLfloat) h,1.0,20.0);
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 gluLookAt(0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
}
void keyboard(unsigned char key,int x,int y)
{

 switch (key){
 case 't':
  month=(month+15)%360;
  glutPostRedisplay();
  break;
 case 'd':
  day=(day+10)%360;
  glutPostRedisplay();
  break;
 case 'D':
  day=(day-10)%360;
  glutPostRedisplay();
  break;
 case 'y':
  year=(year+5)%360;
  glutPostRedisplay();
  break;
 case 'Y':
  year=(year-5)%360;
  glutPostRedisplay();
  break;
 default:
  printf("enter d or D, y or Y");
  break;
 }
}
int main(int argc,char** argv)
{
 glutInit(&argc,argv);
 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
 glutInitWindowSize(500,500);
 glutInitWindowPosition(100,100);
 glutCreateWindow(argv[0]);
 init();
 glutDisplayFunc(display);
 glutReshapeFunc(reshape);
 glutKeyboardFunc(keyboard);
 glutMainLoop();
 return 0;
}





0
artgh (9)
9/20/2003 2:19:57 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

4 Replies
593 Views

Similar Articles

[PageSpeed] 55

Facco Eloelo wrote:
> 
> I writed a programe (using C)  to control two objects:
> keyboard A-------to make the small object rotate
> keyboard Y-------to make the large object rotate
> 
> Now,
> I want to write a *graph user interface* using Tcl to control the objects.It
> should be combined with the C code.
> how can I do it?
> 

The simplest way might be:
- Have your program read the keys from stdin:

  fgets( string, sizeof(string), stdin ) ;

- Start the program via a pipe:

  set outfile [open "|opengl_prog" "w"]

- Create a small script that sends the keys that 
  it reads to the output file $outfile.
  Do not forget to flush the output.

- Check the options to embed an external window - see the man pages
  for frame (I think)

Maybe the Wiki pages on managing Fortran programs will help.
<http://wiki.tcl.tk/2?fortran>

Regards,

Arjen
0
arjen.markus (2628)
9/22/2003 7:22:24 AM
It looks like a setup I did years ago here:

   http://members.tripod.com/~theover/mesa.html

which should work, still.

This is an example which ran on windows 95, and should work on later
versions, an important note being that the socket connection can mess
up in that it can fail to flush buffers even though it is told to, so
that in principle all data still gets transfered between the
applications, but with a (hard to correct) buffer in between  for a
number of lines.

I didn't recently try the example like on XP, or try it on linux,
though I know that many years back even further, HPUX was fine which
such programming.

One poster suggested to use stdio to control your graphics program,
which is NOT going to work under any windows os variant I know of.
Also, the including of windows in another window probably only works
under X servers.

I more recently was informed that probably there has been a problem
with combining the openGL/Mesa library with a select() call under
cygwin, which I used to compile under windows, which may cause the
buffer error which can be noted when more than a few lines in a short
time are send between the tcl and the graphics application.

   Theo Verelst
   theover@tiscali.nl
   http://home.tiscali.nl/theover
0
theover (24)
10/4/2003 2:40:58 AM
Facco Eloelo <artgh@hotmail.com> wrote in message news:<3f6c5e7d.15645385@news.cis.dfn.de>...
> I writed a programe (using C)  to control two objects:
> keyboard A-------to make the small object rotate
> keyboard Y-------to make the large object rotate
> 
> Now,
> I want to write a *graph user interface* using Tcl to control the objects.It
> should be combined with the C code.
> how can I do it?

I had a lot of troubles trying to do something like this. So I have
implemented an OpenGL interpreter in Tcl (for Windows).  It works
great.  Following are the scripts directly translated from your C code
with some modificaiton required by Tk. It is much simpler and works
fine.

global year month day
set year 2003
set month 10
set day 1 

proc globe.init w {
    set old [glw current $w]
    glClearColor 0.0 0.0 0.0 0.0
    glShadeModel GL_FLAT
    glw current $old
}

proc globe.display w {
    set old [glw current $w]

    global year month day
    glClear GL_COLOR_BUFFER_BIT
    glColor 0.0 1.0 0

    glPushMatrix
    glRotate $month 0.0 1.0 0.0
    glutWireSphere 1.0 20 16
    glPopMatrix
    glPushMatrix
    glRotate $year 0.0 1.0 0.0
    glTranslate 2.0 0.0 0.0
    glRotate $day 0.0 1.0 0.0
    glColor 1.0 1.0 0
    glutWireSphere 0.2 10 8
    glPopMatrix
    
    glw draw
    glw current $old
}

proc globe.reshape {w width height} {
    set old [glw current $w]

    glViewport 0 0 $width $height
    glMatrixMode GL_PROJECTION
    glLoadIdentity
    gluPerspective 60.0 [expr $width/double($height)] 1.0 20.0
    glMatrixMode GL_MODELVIEW
    glLoadIdentity
    gluLookAt 0.0 0.0 5.0 0.0 0.0 0.0 0.0 1.0 0.0
    
    glw current $old
}

proc globe.keyboard {w key} {
    set old [glw current $w]
    global year month day
    switch $key {
 	"t" {set month [expr ($month+15) % 360]}
	"d" {set day [expr ($day+10) % 360]}
	"D" {set day [expr ($day-10) % 360]}
	"y" {set year [expr ($year+5) % 360]}
	"Y" {set year [expr ($year-5) % 360]}
	default {puts "enter d or D, y or Y"}
    }

    globe.display $w
    glw current $old
    update
}

proc globe.create w {
    glw $w
    globe.init $w
    bind $w <ButtonPress> "focus $w"
    bind $w <Expose> "globe.display $w"
    bind $w <Configure> "globe.reshape $w %w %h" 
    bind $w <KeyPress> "globe.keyboard $w %K"
    return $w
}

proc globe.test top {
    toplevel $top
    set globe [globe.create $top.gl]
    pack $globe -expand 1 -fill both
    wm geom $top 500x500+100+100
}

To run the scirpt for a test, type

globe.test .globe

More examples can be found at
http://www.geocities.com/~chengye/opengl.html

Chengye Mao
http://www.geocities.com/~chengye

> 
> this is the C code section:
> 
> #include <gl/glut.h>
> #include <stdlib.h>
> #include <stdio.h>
> static int year=0,day=0,month=0;
> void init(void)
> {
>  glClearColor(0.0,0.0,0.0,0.0);
>  glShadeModel(GL_FLAT);
> }
> void display(void)
> {
>  glClear(GL_COLOR_BUFFER_BIT);
>  glColor3f(0.0,1.0,0);
> 
> 
>  glPushMatrix();
>  glRotatef((GLfloat)month,0.0,1.0,0.0);
> glutWireSphere(1.0,20,16);//draw sun
>  glPopMatrix();
>  glPushMatrix();
>  glRotatef((GLfloat)year,0.0,1.0,0.0);
>  glTranslatef(2.0,0.0,0.0);
> glRotatef((GLfloat)day,0.0,1.0,0.0);
>  glColor3f(1.0,1.0,0);
>  glutWireSphere(0.2,10,8);//draw planet
>  glPopMatrix();
>  glutSwapBuffers();
> }
> void reshape(int w,int h)
> {
>  glViewport(0,0,(GLsizei) w,(GLsizei) h);
>  glMatrixMode(GL_PROJECTION);
>  glLoadIdentity();
>  gluPerspective(60.0,(GLfloat) w/(GLfloat) h,1.0,20.0);
>  glMatrixMode(GL_MODELVIEW);
>  glLoadIdentity();
>  gluLookAt(0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
> }
> void keyboard(unsigned char key,int x,int y)
> {
> 
>  switch (key){
>  case 't':
>   month=(month+15)%360;
>   glutPostRedisplay();
>   break;
>  case 'd':
>   day=(day+10)%360;
>   glutPostRedisplay();
>   break;
>  case 'D':
>   day=(day-10)%360;
>   glutPostRedisplay();
>   break;
>  case 'y':
>   year=(year+5)%360;
>   glutPostRedisplay();
>   break;
>  case 'Y':
>   year=(year-5)%360;
>   glutPostRedisplay();
>   break;
>  default:
>   printf("enter d or D, y or Y");
>   break;
>  }
> }
> int main(int argc,char** argv)
> {
>  glutInit(&argc,argv);
>  glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
>  glutInitWindowSize(500,500);
>  glutInitWindowPosition(100,100);
>  glutCreateWindow(argv[0]);
>  init();
>  glutDisplayFunc(display);
>  glutReshapeFunc(reshape);
>  glutKeyboardFunc(keyboard);
>  glutMainLoop();
>  return 0;
> }
0
10/4/2003 7:14:48 AM
In article <f432662e.0310031840.4fa68e8b@posting.google.com>,
Theo Verelst <theover@tiscali.nl> wrote:
			.
			.
			.
>This is an example which ran on windows 95, and should work on later
>versions, an important note being that the socket connection can mess
>up in that it can fail to flush buffers even though it is told to, so
>that in principle all data still gets transfered between the
>applications, but with a (hard to correct) buffer in between  for a
>number of lines.
			.
			.
			.
>One poster suggested to use stdio to control your graphics program,
>which is NOT going to work under any windows os variant I know of.
>Also, the including of windows in another window probably only works
>under X servers.
			.
			.
			.
If you have reproducible examples that demonstrate errors in 
*) flushing of socket I/O
*) stdio communication or
*) window containment
I'm sure that the maintenance squad will give them attention.
I know I rely on each of these, occasionally in flavors of
Windows, and I'm not currently aware of the symptoms at which
you hint.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
10/4/2003 11:43:06 AM
Reply:

Similar Artilces:

l'C program executing from a tcl script with pipe opened using open command in Tcl
Hi all, I wanted to communicate with a C program from a Tcl script.. The test code i have written is below Both the 'C' program and Tcl script are located in the same directory. The 'C' program is below. I have named it CTCL.C #include<stdio.h> #include<string.h> int main() { int i; char c[30]; printf("Reading..."); scanf("%s",c); printf("String read is :%s\n",c); fflush(stdout); return 0; } I have compiled the program with the command cc CTCL.C -o ctcl So the executable was generated with the name 'ctcl' The Tcl script I have written is. I have named it TCLPIPETEST.tcl #!/usr/add-on/exptools/bin/tclsh set fd [open "|./ctcl" r+] gets $fd tmp1 puts "tmp1 = $tmp1" set stat 0 set tmp2 "Default value... " if { ![catch { puts $fd "abcdef" } res]} { if { ![catch { flush $fd } res] } { if { ![catch { gets $fd tmp2} res ] } { set stat 1 } else { puts "Error 'gets' from pipe : $res" } } else { puts "Error 'flush' from pipe:$res " } } else { puts "Error 'puts' from pipe:$res " } if { $stat == 1 } { puts "Success......:$tmp2 :)" } else { puts "Failure......:$tmp2 :(" } I have given all permissions for both the files above. When i execute the Tcl script My aim is to open a pipe with the 'C' executable 'ctcl', initially read so...

Writing new tcl command using c or c++?
Can anyone help me to write new command that can be used in tcl shell using c or c++ code. Himanshu Gupta <himanshulkce@gmail.com> wrote: > Can anyone help me to write new command that can be used in tcl shell > using c or c++ code. Start here: http://wiki.tcl.tk/9849 and here: http://wiki.tcl.tk/21007, read these and then follow and read the links to the other pages from the above two. On Monday, 5 January 2015 14:12:44 UTC+5:30, Himanshu Gupta wrote: > Can anyone help me to write new command that can be used in tcl shell using c or c++ code. Thankyou... On M...

Opening a TCL program from within another TCL program in ANSYS Tcl-Tk
Hi everyone, I have been pulling my hair with this one for a couple of days and still have not found a fix. I'm working within ANSYS Tcl-Tk implementation. I created a Tcl-Tk script that generates a simple window with three buttons. Each button opens another window which is created in a separate Tcl file. The second window have a lot of text entries, variables, procedures, etc. I can open the second Tcl file by itself and everything works as supposed, but when I open it using the button in the first window, it opens but any procedure called by the widgets on the second window are not found... Here's the deal... Since I'm working within the ANSYS implementation of Tcl-Tk, I'm actually using an ANSYS command to open the second window. The command I use is: ### ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' ### It actually sends a command back to ANSYS telling it to execute a Tcl command... I know this is not pretty but its the only way i was able to make it at least show the window. ############################## #Main Tcl (excerpt): ############################## namespace eval Tools { proc IBRCambpell {} { #source O:/mad_projects_2/ANSYS/Macros/IBR_CAS.tcl ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' } proc viewManager {} { ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ ViewManager.tcl' } proc powerAnnotation {} { ans_sendcommand ~eui,'source ...

In Tcl and C++ code, how to use Tcl Command, such as exit?
In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control all input and output from Tcl, but i want to use some of Tcl' Commands, such as, exit. I used Tcl_Eval() then, but the Tcl command seem invisible in my code, I typed a string in command prompt, such as "AAAAA", and Enter, got nothing feedback. How can i do to get these Tcl Commands work? Thanx! vian1381@china.com.cn wrote: > In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control > all input and output from Tcl, but i want to use some of Tcl' Commands, > such as, exit. > > I used Tcl_Eval() then, but the Tcl command seem invisible in my code, > I typed a string in command prompt, such as "AAAAA", and Enter, got > nothing feedback. Your questions are hard to understand, but they suggest that you believe that setting a custom stdin channel will do some magic to establsh a prompt/read/eval loop. That is not the case. > How can i do to get these Tcl Commands work? Start with something that works, like the source code for tclsh, and adapt to your needs. Or post a followup and include more code examples to explain what you're doing and how it doesn't do what you expect. -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter@nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |_____________________________________...

How to write a C program that interacts with tcl?
Hi everyone! I want to write a C program that can interact with tcl by pipeline. This is my C program: # readwrite.c #include <stdio.h> #include <unistd.h> int main(void) { int i,count; char buf[33]; while(1) { memset(buf, 0, 33); read(0, buf, 32); for(i=0;i<64;i++) printf("%x ", buf[i]); printf("\n"); } return 0; } It works very well when you run it in bash shell, just like this: # readwrite abcd 61 62 63 64 a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 But when I invoke this program in tcl scripts, it sucks. This is my wish script: #!/usr/bin/wish button .b1 -text open -command {set fd [open "|/root/readwrite" "r+"]} button .b2 -text close -command {close $fd} button .b3 -text puts -command {puts $fd "24*24\n"; flush $fd;puts [gets $fd]} button .b4 -text exit -command exit pack .b1 .b2 .b3 .b4 I have three questions: 1)When I click the puts button of my mini gui, nothing happens(it does not write anything to the screen) and the button doesn't pop back. I think that this is because the c program didn't get the input from the stdin so when gets, it blocks. Why? 2)When I click the close button of my mini gui, the readwrite program does not quit(you can see that it is still running by ps ax), instead, it keeps writing "0 0 0 0 0....." to my screen. Why? 3)If I ch...

adding events to tcl queue, or using variables and traces (C and TCL)
I'm writing simple testing framework for embedded application. The application is written on C language and runs on microchip PIC microcontroller normally. To test application I made the following: * hardware depended code was picked out from main source and written to separate source files (module_hal.c for example); * two build mode for program: for microchip PIC, using *_hal.c files dealing with real hardware, or for PC, where *_hal.c files contain hardware simulation code and bindings to TCL-commands. Then program was build for PC, I can using TCL commands change input signal states for simulated hardware, for example, or view output signal states. But I need some method to call tcl callback procedure when output signal changes state. I see two methods to achieve this: * map signal state to variable, and then use 'trace' command to bind tcl-scripts to state change events; * add new events to tcl event queue, as described here: http://wiki.tcl.tk/17195 Which method can be more preferable and why? In case if signal state changes too fast, and if I use variable trace, my callback will be called on every state change -- I think it is serious drawback of first method. With second method I can add only one event to queue, and add second only if first event is processed. But as I see, second method requires more complex code in C (now I wrote this code and see it as serious drawback too). May be exists some other methods to call tcl-callbacks on even...

about using tclapp wrap tcl and c program
Hi, all My program is developed with tcl/tk and c, in which I use Tk_Main() and Tcl_AppInit() function to customize my main code. in C function it will execute tcl script by Tcl_Eval(), and in Tcl script it will call the command procedure registered by Tcl_CreateCommand(). Now, I want to use tclapp to wrap my program to one starpack, could you tell me how to do this? Alternatively, the c code can be made one library, then load this library in tcl script. In this case, tclapp will add the base runtime envirnment of tcl/tk, but my c library depends on libtcl84.so and libtk84.so, need I add and wrap these two library repeatedly? Is any method to reduce the size of output. and what I need is starpack not starkit. Best Regards! Tony ...

TCL/TCL combined with Java/C/C++, Any Recommendations?
Hi, I have an application that I wrote in TCL/TK. It has to work with big files +5GB. The parsing performace is not where I would like and some of the data manipulations are taking considerable amount of time due to the data size. Therefore I am considering switching these parts of the code to Java, C or C++. While keepting the GUI and GUI supporting code in TCL/TK at this time. I am trying to figure out which language will be easier to merge with TCL in an application. For C I know that I can compile and generate a .so or .dll and create a TCL package and load it. I believe this is done with SWIG but I have not done it. In Java I saw some info on Jacl and TclBlend. The application will be "compiled" into a TCL "executable". I know I can compile my TCL code into Byte code to protect the IP. I am not sure about Java. Any recommendations or pointers will be greatly appreciated. Thanks in advance, Frank Frank <kranfg@gmail.com> writes: > Hi, > > I have an application that I wrote in TCL/TK. It has to work with big files +5GB. > > The parsing performace is not where I would like and some of the data manipulations are taking considerable amount of time due to the data size. > > Therefore I am considering switching these parts of the code to Java, C or C++. While keepting the GUI and GUI supporting code in TCL/TK at this time. > > I am trying to figure out which language will be easier to ...

Using Tcl/Tk as a user interface in a C program
Hi, i thought this question would come up every day, but i read this NG for a while and haven't seen it since. What i'd like to do is use Tcl/Tk in a standalone (linked against Tcl and/or Tk libs) C program. I'd like to open Windows and call Tcl scripts from C that handle the windows. I wouldn't like to have external scripts called, but i'd like to embed it in the C program. Has anybody got a short example for that (Linux / Windows)? Thanks for any hints, Torsten. MkTclApp is your friend: http://www.hwaci.com/sw/mktclapp/index.html Pretty simple, really. On Tue, 18 Nov 2003, Torsten Mohr wrote: > Date: Tue, 18 Nov 2003 20:05:35 +0100 > From: Torsten Mohr <tmohr@s.netic.de> > Newsgroups: comp.lang.tcl > Subject: Using Tcl/Tk as a user interface in a C program > > Hi, > > i thought this question would come up every day, but i read this > NG for a while and haven't seen it since. > > What i'd like to do is use Tcl/Tk in a standalone (linked against > Tcl and/or Tk libs) C program. > > I'd like to open Windows and call Tcl scripts from C that handle > the windows. I wouldn't like to have external scripts called, but > i'd like to embed it in the C program. > > Has anybody got a short example for that (Linux / Windows)? > > > Thanks for any hints, > Torsten. > > * Torsten Mohr <tmohr@s.netic.de> | I'd like to open Windows and call Tcl sc...

YouTube Playlist: Tcl/Tk Object Oriented Programming Using Itcl (incr Tcl) Lessons
Hi. Like I promised you hours ago.. The playlist in English : https://www.youtube.com/playlist?list=PLsAEIIjTPIo_1qeuc-rYwk0nxWAM38Dl_ The same playlist in Arabic : https://www.youtube.com/playlist?list=PLsAEIIjTPIo_91kA-iUz_5XGNmHzivHBG Enjoy! On Saturday, January 17, 2015 at 4:04:21 PM UTC+2, Rani Ahmad wrote: > Hi. > > Like I promised you hours ago.. > > The playlist in English : > > https://www.youtube.com/playlist?list=PLsAEIIjTPIo_1qeuc-rYwk0nxWAM38Dl_ > > The same playlist in Arabic : > > https://www.youtube.com/playli...

Extending TCL in C with tcl.h - Disabliing [<tcl-cmd>] feature
Hi, TCL has a command execution syntax like this: [<tcl cmd>] Anything inside the 3rd bracket will be executed as a Tcl command by the Tcl interprater. Is there any way I can disable/delete this Tcl construct [ <tcl-cmd>]? In other words, my Tcl interprator should print "[32]" for tcl command puts "[32]" It should not try to treat [] as a special character. Is this any way possible while extending Tcl in C with tcl.h? Thank you, Arijit * arijit79@gmail.com | puts "[32]" | | It should not try to treat [] as a special character. Check out the TCL quoting rules. http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm#M10 http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm#M15 Any of puts {[32]} puts "\[32\]" will do the trick. R' On May 8, 3:14 am, ariji...@gmail.com wrote: > Is there any way I can disable/delete this Tcl construct [ <tcl-cmd>]? By doing this, you would disable the primary functionality of Tcl. I'm certain you could go into the tcl source and stop it - but why not talk about what you are really trying to do. Perhaps someone can give you a better way of doing what you are wanting to do. ...

Connecting a C program with a tcl program with a socket
Dear readers, Several threads on this newsgroup mentioned communication between external programs and a tcl program, or controlling an external program with by a tcl program. In essence, the basic means to do this relatively gracefull is to open a socket (or pipe) connection between the two, and let them communicate over it using messages. Just for those who asked for it or with an interest, not in this case as well throughwrought result of many tests, but an example of how this principle can work in practice, at least it did for me, and did so long in the past, using no all to special means. First, two files to make a C program which at startup waits for a socket connection be established, and when it is connected it reads from the channel and repeates what it reads on the stdout. /* FILE: serv2.c */ /* server exa */ #include "cygwin/socket.h" #include "cygwin/in.h" #include <string.h> #define INMAX 1024 #define LINEMAX 10*1024 #define SERV_TCP_PORT 4100 int sockfd,newsockfd,clilen,childpid; struct sockaddr_in cli_addr, serv_addr; char in[INMAX], line[LINEMAX], rest[LINEMAX]; struct timeval timeout; fd_set fdvar; test_select() { int i; for (i=0; i<10; i++) printf ("select: %d\n",select(newsockfd,&fdvar,(fd_set *) 0, (fd_set *) 0, &timeout) ); } int do_read() { int rr, n, l, i,j; n = INMAX; FD_ZERO(&fdvar); FD_SET(newsockfd, &fdvar); /* printf ("select: %d\n&quo...

tcl as library of c/c++/java program
Hi, All tcl books I know talking how tcl can dynamically load c library. Is any source out there talking about WHO A C/C++/JAVA PROGRAM TO USE TCL AS LIBRARY? Thank, alex "tak" <tak416@yahoo.com> wrote > All tcl books I know talking how tcl can dynamically load c library. > Is any source out there talking about WHO A C/C++/JAVA > PROGRAM TO USE TCL AS LIBRARY? Start with http://phaseit.net/claird/comp.lang.tcl/HowToC.html but some people think that you can choose a better overall architecture. http://mini.net/tcl/9303 If you choose to use Tcl libraries "the old fashioned way,", the most of the advice you read about how to write extensions applies to adding Tcl interfaces to your existing C/C++ code. See http://mini.net/tcl/1191. Java is a slightly different case, because wave have Jacl and TclBlend. Search for them on the Wiki, and you'll find other resources. Bob -- Bob Techentin techentin.robert@NOSPAMmayo.edu Mayo Foundation (507) 538-5495 200 First St. SW FAX (507) 284-9171 Rochester MN, 55901 USA http://www.mayo.edu/sppdg/ In article <bfmaqa$b4u$1@tribune.mayo.edu>, Bob Techentin <techentin.robert@mayo.edu> wrote: . . . >Start with >http://phaseit.net/claird/comp.lang.tcl/HowToC.html . . . Ugh. My, is *that* in need of editing: typos, broken links, .... It might be month before I get to it, th...

following tcl command execution from C/C++ code to tcl in gdb
Hi, We have a C/C++ huge application that makes heavy use of tcl C bindings. We frequently have very long stack traces from within gdb/dbx that look like this: #7 0x0d0aac7d in TclObjInterpProc (clientData=0x12857160, interp=0x10924df8, objc=6, objv=0x15138a40) at ../generic/tclProc.c:1146 #8 0x0d043dc6 in TclEvalObjvInternal (interp=0x10924df8, objc=6, objv=0x15138a40, command=0xe0c1382 "", length=0, flags=262144) at ../generic/tclBasic.c:3087 #9 0x0d044045 in Tcl_EvalObjv (interp=0x10924df8, objc=6, objv=0x15138a40, flags=262144) at ../generic/tclBasic.c:3203 This is just a very small part of what can be a very long stack trace. Now by poking around I can see that in gdb I can print *objv[0] to see the first word of a command but this is painful. What we really want is a way to see what Tcl commands are being executed either while the program is running or easily from the stack trace. Can you run gdb as well as a Tcl debugger at the same time? Seems unlikely. How are people systematically tracing the execution of Tcl commands that are called from C/++ bindings? Thanks. foobarbaz99@hotmail.com wrote: > How are people systematically tracing the execution of Tcl commands > that are called from C/++ bindings? Are you familiar with Tcl_CreateObjTrace() ? Does it accomplish what you need? -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter@nist.gov Information Technology Laboratory | | http://mat...

How to use Tcl for c code testing using VxWorks
This is Harika. I would like to know how to use tcl in c for testing, in VxWorks operating system. If possible give me example. I have written for unit level testing but iam getting error saying that interep is not found. But i have to do for automation absolutely. Let me know does Expect is necessary for automation. I didn't get Explore Expect book in chennai.I would be so thank full if any one do favour for me. Awaiting for the reply, Thanking you. In article <1176120872.799611.271860@d57g2000hsg.googlegroups.com>, Harika <harika.it@gmail.com> wrote: >This is Harika. I would like to know how to use tcl in c for testing, >in VxWorks operating system. If possible give me example. I have >written for unit level testing but iam getting error saying that >interep is not found. But i have to do for automation absolutely. Let >me know does Expect is necessary for automation. I didn't get Explore >Expect book in chennai.I would be so thank full if any one do favour >for me. . . . Tcl is quite handy for testing <URL: http://wiki.tcl.tk/testing >. While Expect is widely used in testing, and has been very successful in that role, it is not necessary, as the URL above will explain. For unit testing of the sort you seem to be targetting, SWIG <URL: http://wiki.tcl.tk/swig > might be helpful. ...

Using TCL with C#
I am trying to call TCL from my C# application and found some useful help on the Wiki website http://wiki.tcl.tk/9563 (as shown below). using System.Runtime.InteropServices; using System; namespace TclWrap { public class TclAPI { [DllImport("tcl84.DLL")] public static extern IntPtr Tcl_CreateInterp(); [DllImport("tcl84.Dll")] public static extern int Tcl_Eval(IntPtr interp,string skript); [DllImport("tcl84.Dll")] public static extern IntPtr Tcl_GetObjResult(IntPtr interp); [DllImport("tcl84.Dll")] public static extern string Tcl_GetStringFromObj(IntPtr tclObj,IntPtr length); } public class TclInterpreter { private IntPtr interp; public TclInterpreter() { interp = TclAPI.Tcl_CreateInterp(); if (interp == IntPtr.Zero) { throw new SystemException("can not initialize Tcl interpreter"); } } public int evalScript(string script) { return TclAPI.Tcl_Eval(interp,script); } public string Result { get { IntPtr obj = TclAPI.Tcl_GetObjResult(interp); if (obj == IntPtr.Zero) { return ""; } else { return TclAPI.Tcl_GetStringFromObj(obj,IntPtr.Zero); } } } } } However, when I use the Tcl_Eval command and pass the TCL command "source script1.tcl" or "file exists script1.tcl" (or any of the other file command), it causes an exception in my C# application. It works fine when you pass TCL commands ...

Using Tcl/Tk 8.4.7 from C/C++
Hi, I just discovered Tcl/Tk and fairly excited about it :) I'm interested in using both Tcl/Tk on one c++ project and only Tk on another c++ project. 1. C++ Tk only project: I'm interested in using Tk within my c/c++ project. The project only has 5-6 dialogs using just the standard widgets. Is it fairly common to use Tk directly from c/c++--and is it fairly easy? 2. C++ Tcl/Tk only project: I'm interested in using both Tcl and Tk from within a c/c++ application. Is maketclapp the best way to go or are there better ways? Maketclapp doesn't seem to have been updated in a while...but the security features (hiding tcl source) is compelling for this particular project. Thanks. ...

Tcl Book that explains tcl C API?
Hi! I am looking for material that explains the tcl C API in order to: - Embed Tcl into a C application. - Extend Tcl to add new commands in C. Does Tcl and Tk Toolkit (2nd Edition) by Ken Jones and John Ousterhout do a good job explain these topics in depth? Thanks! Asif wrote: > Hi! > > I am looking for material that explains the tcl C API in order to: > > - Embed Tcl into a C application. > - Extend Tcl to add new commands in C. > > Does Tcl and Tk Toolkit (2nd Edition) by Ken Jones and John Ousterhout do > a good job explain these topics in depth? > > Thanks! can help you cheap:; http://freecomputerbooks.com/langTclBooks.html -- -- -- What's on Shortwave guide: choose an hour, go! http://shortwave.tk 700+ Radio Stations on SW http://swstations.tk 300+ languages on SW http://radiolanguages.tk marc wrote: > Asif wrote: > >> Hi! >> >> I am looking for material that explains the tcl C API in order to: >> >> - Embed Tcl into a C application. >> - Extend Tcl to add new commands in C. >> >> Does Tcl and Tk Toolkit (2nd Edition) by Ken Jones and John Ousterhout do >> a good job explain these topics in depth? >> >> Thanks! > > > can help you cheap:; > http://freecomputerbooks.com/langTclBooks.html Would you really trust a site which *PRESUMES* the whole world uses their preferred settings and the heck with the visually imperfect. The resu...

Tcl to C or C++
Hi all, does anyone know some tool (free or not) capable to translate Tcl source code to C or C++? Of course I believe to translate only a subset of Tcl language (1), while statements like this: #...some code that algorithmically generate the string a, where a is # almost-arbitrary code eval $a cannot be translated at all, except with somewhat complex solutions! Thank you (1) I'm thinking to traslate Tcl source code written using a subset of Tcl keywords and by following some coding rules; for example I'd avoid this: #...some code that calculates a and b set $a$b 0 Stefano Chiappa Dear Stefano, Is there a reason for wanting this convertion? As I have tried to do such a project in the past, it turned out that the resulting C code was much more slower & memory wasting than the corrsponing tcl code, so I gave up :-) So, for such a tool a severe investment on optimisations has to be made, in order for the generated C code to be of use. I remember that there was at least one such commercial compiler in the past, but I don't know if it is still active. See for example: http://groups.google.com.gr/groups?q=aotto+compiler&hl=el&lr=&group=comp.lang.tcl.*&selm=pgpmoose.200101222138.11399%40non.non.net&rnum=1 I remember that I had tested the compiler and indeed it gave some speedup over the tclc code. However, I believe the speedup was due to the heavy optimisation that was done by the author, and not from the fact that it was converted i...

FAQ (unanswered): possible to use Tk without Tcl (in c/c++)
Googling turned up dozens of questions about using tk without tcl. But there doesn't seem to be a clear answer. Is it possible to use Tk without Tcl? Specifically, I'd like to use Tk from c/c++ without using Tcl. More specifically, I'd like to statically link in the Tk library and use it directly from c/c++. H. Simpson wrote: > Googling turned up dozens of questions about using tk without tcl. But > there doesn't seem to be a clear answer. > > Is it possible to use Tk without Tcl? > > Specifically, I'd like to use Tk from c/c++ without using Tcl. More > specifically, I'd like to statically link in the Tk library and use it > directly from c/c++. The Perl/Tk people did it. The Python/Tkinter people took the other route of embedding a Tcl interpreter along with it. It is possible, but its wasting a lot of Tk's capabilities, that come from the Tcl language. A second problem is the Tk C-Api. Do you have any special reasons to use Tk without Tcl? Michael Michael Schlenker wrote: > H. Simpson wrote: > >> Googling turned up dozens of questions about using tk without tcl. >> But there doesn't seem to be a clear answer. >> >> Is it possible to use Tk without Tcl? >> >> Specifically, I'd like to use Tk from c/c++ without using Tcl. More >> specifically, I'd like to statically link in the Tk library and use it >> directly from c/c++. >...

how to write some to notepad using tcl?
I like write a tcl to do as follows: 1.open windows notepad. ----> exec notepad 2.write "hello world" to notepad ---->? 3.save and close this file.(may not need to closed it ) ----->? Is it possible? if yes, how to do it? Thanks, young, steven young wrote: > I like write a tcl to do as follows: > 1.open windows notepad. ----> exec notepad > 2.write "hello world" to notepad ---->? > 3.save and close this file.(may not need to closed it ) ----->? This is very weird. I don't understand what exactly are you trying to accomplish. First of all, it is possible to use Windows programs using COM. This way you should be able to write a simple script that does just that with ms word. I'm not sure however if notepad has any COM interface, probably not. If you want to present a user with a text editing window, you could use Tk for that. It shouldn't be hard to write a notepad-like script. Perhaps describe in detail what you want the program to do, and someone will help you if it is possible. -- WK steven young wrote: > I like write a tcl to do as follows: > 1.open windows notepad. ----> exec notepad > 2.write "hello world" to notepad ---->? > 3.save and close this file.(may not need to closed it ) ----->? There are several extensions to do this. Look for cwind, wintclsend and sendkeys. -- Jeff ...

tcl code to read an image and write tcl code?
Does anyone know where I can find a tcl proc that would take an image, say a gif, and output pure tcl code that I could paste into a program? I saw something about a unix program that did something with mimes but I'm on windows. In article <4403BC94.447A7341@rocketship1.com>, Eric Taylor <et2@rocketship1.com> wrote: > > >Does anyone know where I can find a tcl proc >that would take an image, say a gif, and output >pure tcl code that I could paste into a program? > >I saw something about a unix program that did >something with mimes but I'm on windows. > > I think TkProE (http://tkproe.sourceforge.net) can do this. A quick look suggests that the procs TP_ImageToData & TP_ImageEncode might do what you want. Ted Eric Taylor wrote: > Does anyone know where I can find a tcl proc > that would take an image, say a gif, and output > pure tcl code that I could paste into a program? > > I saw something about a unix program that did > something with mimes but I'm on windows. > > Something like this ought to be pretty close (untested, but I think it's pretty close). It requires the base64 package from tcllib: package require base64 proc main {} { global argv set file [lindex $argv 0] set fd [open $file r] set rawdata [read $fd] close $fd set b64data [base64::encode $rawdata] puts "image create photo -data {\n$b64data\n}" } mai...

Tcl interface to C program
I am developing a program (a game) that has two main states: one is the actual game which is a low-level full screen C program that must be very optimized; the other is a textual interface where the player sets options like difficulty, save games, colors, etc. For example, while playing the game the user can press Esc to pause the game and go into the text interface. I was thinking of using Tcl as the text interface. Does anyone have any pointers on how to do this? I would like to design it so the main() part of the program is Tcl, with a command lets the user switch into the full screen C game (which would be like a module). How does that work? Can it all be combined into one executable file? Any help would be appreciated. bluejolts@gmail.com schrieb: > I am developing a program (a game) that has two main states: one is > the actual game which is a low-level full screen C program that must > be very optimized; the other is a textual interface where the player > sets options like difficulty, save games, colors, etc. For example, > while playing the game the user can press Esc to pause the game and go > into the text interface. text interface aka tty on unix or dos console on windows? Another option would be to use Tk for a gui. > > I was thinking of using Tcl as the text interface. Does anyone have > any pointers on how to do this? For tty's look at the tcllib term package, which does ansi escape sequences and cursor movement stuff in ansi...

using TCL on windows in C#
I'd like to store my init.tcl in a non-default path. I tried the following code: TCL tcl = new TCL(); tcl.SetVar("TCL_LIBRARY", "C:/some/path"); // Tcl_SetVar tclResult = tcl.InitInterpreter(); // Tcl_Init But my application crashes. If I comment out the tcl.SetVar line then the application does not crash but Tcl_Init returns 1 with the following predictable message: "Can't find a usable init.tcl in the following directories: \n C:/QA/Pcdlrn/Win32/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.6/library ./tcl8.5.6/library\n\n\n\nThis probably means that Tcl wasn't installed properly.\n" Is it possible to programmatically set the TCL_LIBRARY path via C# before calling Tcl_Init? Any help would be greatly appreciated. Thank you very much. My TCL wrapper code is below: public class TCL { [DllImport("tcl85.DLL", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr Tcl_CreateInterp(); [DllImport("tcl85.DLL", CallingConvention = CallingConvention.Cdecl)] public static extern int Tcl_Init(IntPtr interp); [DllImport("tcl85.DLL", CallingConvention = CallingConvention.Cdecl)] public static extern String Tcl_SetVar(IntPtr interp, string varName, string newValue, int flags); [DllImport("tcl85.DLL", CallingConvention = CallingConvention.Cdecl)] public static extern int T...

Web resources about - How to use tcl to write a GUI to control a C program - comp.lang.tcl

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Islamic State uses birth control to maintain supply of sex slaves
Modern methods allow the Islamic State to keep up its systematic rape of captives under medieval codes.

Islamic State uses birth control to maintain supply of sex slaves
Modern methods allow the Islamic State to keep up its systematic rape of captives under medieval codes.

Islamic State using birth control to keep supply of sex slaves
Islamic State using birth control to keep supply of sex slaves - NY Times swissinfo.ch WASHINGTON (Reuters) - The Islamic State is using several ...

Yet another “critical” Flash vulnerability allows an attacker to take control of your Mac – fix available ...
Adobe has announced the latest in a long line of “critical” Flash vulnerabilities , allowing an attacker to take control of your Mac. The same ...

Dam you! Justice Dept. to indict Iranians for probing flood control network
The gate to the Bowman Avenue Dam facility in Rye Brook, NY is locked, but the cellular modem used for its controls wasn't. (credit: Google) ...

DIRTY LITTLE SECRETS OF GUN CONTROL: Fraud, Theatrics, and Murder in Obama's Adopted Hometown
By Institute for Legislative Action President Obama’s hometown of Chicago has been controlled by his political party since at least 1931. The ...

LIES, BOOZE, AND BILLIONS: How one of the fastest-growing startups in Silicon Valley history raised $580 ...
... disagreements the two men would have over how to run Zenefits in the next year. A year later, by this February, Zenefits had spun out of control ...

'Creative Control' is a cautionary tale about getting too personal with tech
The film explores how tech has taken over our lives by dropping us into a world where devices are see-through and everyday augmented reality ...

The Legend of Zelda: Twilight Princess HD nearly had Wiimote controls
... Tantalus, an Australian developer (who also ported Mass Effect 3 to Wii U), to handle the port. The team also considered using Wiimote controls, ...

Resources last updated: 3/13/2016 8:42:13 PM