Creating lists in Tcl 8.0 using Object 
Author Message
 Creating lists in Tcl 8.0 using Object

Hi,

I need to write a C function using Tcl 8.0 library.
In this function I need to create 3 lists containing strings, and then
sending as the result a list containg these 3 lists.
I can create the 3 lists of strings using Tcl_Merge but then I have a
problem: how can I create the result list containg these 3 lists.

I'd also like to use the new object API, because it may be faster to
execute.

Thanks  



Fri, 17 Mar 2000 03:00:00 GMT  
 Creating lists in Tcl 8.0 using Object

Quote:

> Hi,

> I need to write a C function using Tcl 8.0 library.
> In this function I need to create 3 lists containing strings, and then
> sending as the result a list containg these 3 lists.
> I can create the 3 lists of strings using Tcl_Merge but then I have a
> problem: how can I create the result list containg these 3 lists.

With great ease. First you make an empty list object with
result = Tcl_NewListObj(0, NULL);

Then you append each of the other lists to it with
Tcl_ListObjAppendElement(interp, result, partresult);

...and make sure your hack returns this, with
Tcl_SetObjResult(interp, result);

So far this sort of stuff works for me with no problems...
        --Jasper



Sun, 19 Mar 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need an example to create lists in Tcl 8.0 using Object

2. passing a list of created objects to a tcl script

3. Tcl 8.0 BUG when creating invalid line in canvas

4. Accessing Global variables/objects from C code in Tcl 8.0

5. Is this a bug - list handling in TCL 8.0

6. Object-orientation for Tcl/Tk 8.0?

7. TclBin 1.2 {full binary objects structures and IO for Tcl 7.3 to 8.0}

8. Porting to the Tcl 8.0 object interface

9. custom Tk_Main using Tcl/Tk 8.0

10. Problems with HP-UX 8.0 and Tcl/TK 8.0

11. Problem with modal dialog when using Tcl/Tk 8.0

12. Tcl 8.0 lib using WATCOM?

 

 
Powered by phpBB® Forum Software