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