home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / tcl / 1055 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.1 KB  |  60 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!ghostwind!shmdgljd
  3. From: shmdgljd@rchland.vnet.ibm.com (Jay Schmidgall)
  4. Subject: Re: How do I imbed tcl in an application
  5. Sender: news@rchland.ibm.com
  6. Message-ID: <1992Jul28.114518.12123@rchland.ibm.com>
  7. Date: Tue, 28 Jul 1992 11:45:18 GMT
  8. Reply-To: jay@vnet.ibm.com
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. References: <1992Jul27.175107.7633@rchland.ibm.com> <ADRIANHO.92Jul27175403@barkley.berkeley.edu>
  11. Nntp-Posting-Host: ghostwind.rchland.ibm.com
  12. Organization: IBM Rochester, MN
  13. Lines: 45
  14.  
  15. In article <ADRIANHO.92Jul27175403@barkley.berkeley.edu>, adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
  16. |> A pretty good example is in the Tcl distribution itself: tclTest.c is
  17. |> a simple Tcl command-shell.
  18.  
  19. Thanks to Adrian and the off-line responses.  The consensus seems to be look
  20. at how tclTest works, which I am in the process of doing.
  21.  
  22. Question 2: (long winded, sorry)
  23.  
  24. How do I provide access to structures more complex than just strings?
  25.  
  26. For example, I've got a structure 
  27.  
  28. typedef struct {
  29.     char *name;
  30.     int  rank;
  31.     int  ssn;
  32. } Soldier;
  33.  
  34. Soldier grunt;
  35.  
  36. Now, is there any way I can pass ``grunt'' to a tcl proc and have it be
  37. able to access grunt.name or grunt.rank ?
  38.  
  39. I was thinking that I would do this by adding a new command, say soldier,
  40. which would be like
  41.  
  42.     soldier name x : returns x.name
  43.     soldier rank x : returns x.rank
  44.     soldier ssn x  : returns x.ssn
  45.  
  46. But I'm still left with the problem of x being a Soldier, rather than a
  47. string.  For that matter, how would I initialize x.name?
  48.  
  49. Hmmm.  I guess what I'm wondering is sort of how other people have made
  50. the association between a string and the more complex data structure of
  51. which that string is just the name? a pointer to it, somehow? ??
  52.  
  53. I hope this makes sense.
  54.  
  55. (In the meantime, I'll look at tk as well to see how the man did it for
  56.  windows, etc.)
  57. -- 
  58. : jay          jay@vnet.ibm.com    My opinions and ideas, not my employer's.
  59. : shmdgljd@rchland.vnet.ibm.com    (c) Copyright 1992.  All rights reserved.
  60.