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

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!mnemosyne.cs.du.edu!nyx!tpoindex
  3. From: tpoindex@nyx.cs.du.edu (Tom Poindexter)
  4. Subject: Re: How do I imbed tcl in an application
  5. Message-ID: <1992Jul29.132245.4902@mnemosyne.cs.du.edu>
  6. Sender: usenet@mnemosyne.cs.du.edu (netnews admin account)
  7. Organization: Nyx, Public Access Unix @ U. of Denver Math/CS dept.
  8. References: <1992Jul27.175107.7633@rchland.ibm.com> <ADRIANHO.92Jul27175403@barkley.berkeley.edu> <1992Jul28.114518.12123@rchland.ibm.com>
  9. Date: Wed, 29 Jul 92 13:22:45 GMT
  10. Lines: 41
  11.  
  12. In article <1992Jul28.114518.12123@rchland.ibm.com> jay@vnet.ibm.com writes:
  13. >Question 2: (long winded, sorry)
  14. >
  15. >How do I provide access to structures more complex than just strings?
  16. >
  17. >For example, I've got a structure 
  18. >
  19. >typedef struct {
  20. >    char *name;
  21. >    int  rank;
  22. >    int  ssn;
  23. >} Soldier;
  24. >
  25. >Soldier grunt;
  26. >
  27. >Now, is there any way I can pass ``grunt'' to a tcl proc and have it be
  28. >able to access grunt.name or grunt.rank ?
  29.  
  30.  
  31. I would suggest looking into the Handles(TCL) code (part of Extended TCL), 
  32. or possibly using Keyed Lists (also in Extended TCL).  
  33.  
  34. If all your structure elements can be represented as strings, I'd say go for
  35. Keyed Lists.  If your structure has more difficult elements, say pointers,
  36. then go for Handles.  
  37.  
  38. I've recently written a TCL to Sybase package (which I soon hope to release)
  39. that uses the Handles approach, but without using the Handles code.  I
  40. wrote my own struct access functions, similar to how files are treated in
  41. the base TCL code.  I have a routine to connect to a database; if successful,
  42. my code looks for an unused slot in a fix array of structs, and returns a
  43. "handle" string.  The handle is then passed to every other database access
  44. command as the first argument.  Each command decodes the handle into an
  45. index into the array.  
  46.  
  47. Regards,
  48. Tom Poindexter
  49.  
  50. --
  51.  
  52. Tom Poindexter     tpoindex@nyx.cs.du.edu      (What? You were expecting more?)
  53.