f



how to get Tcl array values in C++ code

Does anyone know how to get array value in c++ code ? Just like :

In tcl script :

array set foo { johnny 12 Tom 11 Tim 14 }


In c++ code :

Tcl object * obj = Tcl_GetArray( interp, "foo" );
while( Tcl_GetArrayNextObjectFunc( obj, &key, &value ) {
  ...
}

I don't know if there is a function can get array values. Thanks ~~~

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---
0
Johnny
10/18/2011 11:45:03 AM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

2 Replies
529 Views

Similar Articles

[PageSpeed] 24

On 18/10/2011 12:45, Johnny Zhou wrote:
> Does anyone know how to get array value in c++ code ? Just like :

I think you're looking for Tcl_GetVar2Ex, which takes the array name as 
one of its arguments and the element name as another. (There are other 
arguments besides.)

If you're looking to get the whole array, the Tcl C(++) API does not 
provide that facility (in part because arrays are not values in Tcl, but 
rather collections of variables). Why do you want it? We might be able 
to provide a suitable workaround using something that is supported.

Donal.
0
10/18/2011 1:45:47 PM
* Johnny Zhou <0121517@163.com>
| In tcl script :
| array set foo { johnny 12 Tom 11 Tim 14 }
>
| In c++ code :
| Tcl object * obj = Tcl_GetArray( interp, "foo" );
| while( Tcl_GetArrayNextObjectFunc( obj, &key, &value ) {
|   ...
| }
| I don't know if there is a function can get array values.

We have simply encoded the

  array startsearch arrayname
  array nextelement arrayname searchid
  array donesearch arrayname searchid

sequence in C via TclEval*().  Not the most efficient I suppose, but...

R'
0
ralfixx (1283)
10/19/2011 10:43:37 AM
Reply:

Similar Artilces:

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 wi...

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 ...

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. ...

A problem when using SWIG to integrate C code into TCL code
Hi all, I met the folowing error when using SWIG to integrate C code into TCL code, can somebody help me? Thanks a lot! 1. First I created a file named fun.c: double myfun(int n) { double res=1.0; int j; for (j=1;j<=n;j++) res *= j; return(res); } 2. I created a interface file named fun.i: %module myfun extern double myfun(int); 3. I run the following command and two new files were created: swig -tcl fract.i 4. build the object file gcc -c fun.c fun_wrap.c gcc -shared -o myfun.so fun.o fun_wrap.o 5. In my TCL file, add the following command: ..... load ./myfun.so; .......

Symbol Table parser in TCL for C/C++ compiled code...
i was wondering if there is a magic tcl symbol table parser, extractor for C/C++ code that is compiled with debug options turned on. any help is appreciated On 6 Dec 2005 04:29:38 -0800, "Mel" <mel.heravi@cae.com> wrote: >i was wondering if there is a magic tcl symbol table parser, extractor >for C/C++ code that is compiled with debug options turned on. > >any help is appreciated Hi Mel, I don't have any direct answer, just some thoughts. This will be highly compiler (and maybe even version) specific. What I would do: 1) Create a map file. This is a human re...

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...

how to debug tcl running under tcl interep in C++ exe
Hi: I have a C++ exe, which has a tcl interep and loads some tcl files. The exe throws a tcl shell to user where user enters tcl scripts. I want to debug the tcl files while these exe runs. Is there any way/debugger to do this? Regards --Sourav Sourav Sircar schrieb: > Hi: > I have a C++ exe, which has a tcl interep and loads some tcl files. > The exe throws a tcl shell to user where user enters tcl scripts. > I want to debug the tcl files while these exe runs. Is there any > way/debugger to do this? > Regards > --Sourav You could probably load the comm packa...

Traversing TCL array in C
Hi, Is there any examples of traversing TCL array in C? I'm playing around with tcl module for Freeradius. On eash request, I create TCL array with Tcl_SetVar2 using radius attribute as KEY, and attribute's value as array value. (Acctually I use TCL_APPEND_VALUE and TCL_LIST_VALUE because there may be multiple values for the same attribute.) and pass it to tcl interpeter. After that I wish to convert array back to radius attributes, but don't know how to traverse array in C. Any hints? Thanks in advance. In article <1114613363.014635.132750@l41g2000cwc.googlegroups.com>...

Remembering Tcl: Problems with C and Tcl communicated via pipelines
I am now remembering TCL and I have came across with a problem when doing something I used to do. My purpose is to implement a console-like GUI to present in a listbox outputs from another program written in c and allow to command orders via an entry. All the communication between both programs will be via pipeline As a first approximation, I tried several easy examples and I get stucked with these two programs (see below). When executing tclprogram2.tcl I get Done1 and Done2 and nothing more: i must end it with Ctrl-C. However, if I change Hello3 lines before for loop, the program run smoo...

tcl-mmap: A POSIX mmap interface for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-mmap Tcl-mmap is a Tcl interface to the POSIX mmap* system call. It provides a Tcl package that allows Tcl scripts to: 1) Memory map files for improved access efficiency; 2) Share memory between related processes; 3) Easily implement cyclic persistent log files. * See the mmap(2) man page. Platform: Linux/Unix Home page: http://sourceforge.net/projects/tcl-mmap/ Man page: http://tcl-mmap.sourceforge.net/ Author: Alexandros Stergiakis On Sep 3, 11:48=A0am, Alexandros Stergiakis <alst...@gmail.com> wrote: > This is an ...

tcl-syslog: Unix system logging for Tcl (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-syslog Tcl-syslog is a Tcl interface to the *nix syslog service. It provides a Tcl package that allows Tcl scripts to log messages to syslog. Platform: Linux/Unix Home page: http://sourceforge.net/projects/tcl-syslog/ Man page: http://tcl-syslog.sourceforge.net/ Author: Alexandros Stergiakis alsterg ...

COM / My C++ Code and my TCL Inspector
i like to be able to examine my C++ objects from outside of my running application using COM objects. I heard about inheriting my classes from IDispatch (true or not). Can someone please point me in the right direction. Is this a BIG undertaking or a minor tweeking of my code. Many thanks in advance ...

reading a value from a tcl list in C++
Hello, I have a c++ extension with a recursive function. It works fine until a certain point where the recursion is too deep and then Wish just closes. There are no error messages or anything... Wish just closes. I've narrowed it down to the following piece of code. Basically, I'm trying to get a value at a certain index in a list and then returning if it doesn't equal 0. // Get the pointer to the $::IntMap list. Tcl_Obj *listPtr = Tcl_ObjGetVar2(myInterp, Tcl_NewStringObj("IntMap", -1), NULL, TCL_GLOBAL_ONLY); Tcl_IncrRefCount(listPtr); // Get the value of the el...

tcllib: C extensions + tcl code ?
Hello, Yes, I know that tcllib is a pure tcl library, but suppose some of tcl procs have faster (same capability, api etc) C functions. Is it possible to distribute in tcllib, both the tcl versions as well as the C extension, leaving it up to the user to compile the C code or not? Aamer Akhter wrote: > Hello, > > Yes, I know that tcllib is a pure tcl library, but suppose some of tcl > procs have faster (same capability, api etc) C functions. > > Is it possible to distribute in tcllib, both the tcl versions as well > as the C extension, leaving it up to the user to co...

tcl array size and elements in c
How can I find the size of a tcl array and the name of individual array indexes from in my c extension? mah wrote: > How can I find the size of a tcl array and the name of individual array > indexes from in my c extension? It's a little weird, but Tcl_HashStats returns a string formatted in a specific way with size info, but for iterating over names, you use the other Tcl_*Hash* functions. -- Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos Thank you Jeff for pointing me to the right functions. However I could not find any example on the web which...

returning updating c values from tcl
I am trying to write a simple front end front end for a C program. The idea is to update a variable and call a function each time a button is clicked. I am using mktclapp and Tcl_Linkvar and It works fine for the following script: #---------------- set linkedVar 6 button .b -text Go -command START_DRIVER button .e -text Quit -command exit pack .b .e -side left #---------------- But for this script, linkedVar is not updated: #---------------- button .b -text Go -command doIt button .e -text Quit -command exit pack .b .e -side left proc doIt {} { set linkedVar 6 START_DRIVER } #-----...

How does the Tcl interpret handle results returned from C-created Tcl commands ?
I've ventured on creating a Tcl command trough a C routine. I've followed the manual guidelines. My C routine checks the validity of a selected option for the currently displayed histogram. Therefore it returns a Boolean value that, according to the C <-> Tcl communucation protocol, I have encoded as TCL_ERROR (= FALSE) and TCL_OK (TRUE). WHenthis command is called in a Tcl proc, the interpreter is supposed to perform two different actions according to the returned Boolean value. How can I fetch this returned Boolean result (TCL_ERROR/ TCL_OK) from the Tcl proc that executes the C-created command ? What if I wrote 1 (FALSE) or 0 (TRUE) in a string and have the C routine return this 1-character string ? Would it be easier to get the result of the teest from the caling TCL proc ? Please, find in the following the code that implements (according to my best resolution) the C-created command and the callind Tcl proc. Thank you, Maura ************************************************************************************************************* * C routine * ************************************************************************************************************* static int check_hist_aint_option_cb( ClientData clientData, Tcl_Interp *interp, int argc, char *argv[] ) { int i; if ( hg.active_ &...

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...

Getting values from array of arrays
I have a drop down list in my view. In my model I have the following: ARTICLE_CATEGORIES = [ ["News", 1], ["Article", 2], ["Review", 3] ] validates_inclusion_of :category, :in => ARTICLE_CATEGORIES.map { |disp, value| value } I want to extract out all "Article" types in my controller. So in my controller: (I have a 'category' field in my 'articles' table) @news = Article.find_by_category(ARTICLE::ARTICLE_CATEGORIES.find...??) Not sure how to do this. I want to get the ID (in this cas...

getting values in an array of arrays
Hi, The following is the output of a print_r on an array. The value of element[0] is itself an array. How do I access the elements in the second array? Array ( [0] => Array ( [Vancouver] => Vancouver [Eugene] => Eugene [Beaverton] => Beaverton ) ) I've tried to set $c[] = $city[0], but this just outputs the same result. Thanks, Sal ..oO(speralta@progressivetrail.org) >The following is the output of a print_r on an array. The value of >element[0] is itself an array. How do I access the elements in the >second array? $foo[1st level][2nd level][3rd level] Mi...

C++/Tcl/C++ Interface
Hi, I'm a newbie in Tcl and Tcl/C++ interfacing. I need to develop a prototype for one of our upcoming project. I've a shared library which provides Tcl procedures to traverse through some graph which is being created upon reading a file of specific format. If I load this shared library in Tcl shell and call those proc to read the specific file and traverse the graph. Graph traversal proc are like: * getting neighbor nodes of a given node * getting the node name and edge names to/from a node Let's name this Tcl library GL (graph lib). Now, in my C++ program I need cre...

mojolicious and realtime web, events getting thier do? does tcl do this ? when tcl be epoll based?
https://www.youtube.com/watch?v=HRWzhJDyHB8 ...

Need to get a javscript variable into my tcl code
Hello, I have a difficult task I believe. I have tcl code that opens a webpage, then via execScript commands calls javascript code to play audio files for my js object player. The problem is that I need to know when the clip is done for example to have my tcl code check for that. Has anyone been able to pass a javascript variable to tcl code, or has had a work around to this?? Here is what I have so far: tcl code (I am using optcl to open the page in a tk window): # set tk window package require optcl set t [toplevel .ie] wm title $t "my Test" set htm [optcl::new -window $t.htm ...

Tcl C API to get OS version?
What's the best way to get the OS version you are running on via Tcl's C API? I'm using some platform-specific calls in the C package I'm developing, but I'd rather use a Tcl function (C, not script-level) if possible. Please advise. -- Kevin Walzer Code by Kevin http://www.codebykevin.com * Kevin Walzer <kw@codebykevin.com> | What's the best way to get the OS version you are running on via Tcl's | C API? I'm using some platform-specific calls in the C package I'm | developing, but I'd rather use a Tcl function (C, not script-level) if | possible. Look at the tcl_platform array via Tcl_GetVar2Ex()? % parray tcl_platform ... tcl_platform(osVersion) = 2.6.34.10-0.4-desktop ... => Tcl_Obj *osversion = Tcl_GetVar2Ex(interp, "tcl_platform", "osVersion", TCL_GLOBAL_ONLY); R' ...

Web resources about - how to get Tcl array values in C++ code - comp.lang.tcl

Values Voter Summit - Wikipedia, the free encyclopedia
The Values Voter Summit is an annual political conference for American social conservative activists and elected officials from across the United ...

Facebook Is No. 5 on Glassdoor’s Top 25 Companies for Culture & Values
Facebook placed fifth on the 2014 list of Top 25 Companies for Culture & Values from social jobs and career community Glassdoor , which was released ...

Glassdoor: Facebook rated No. 5 nationally in culture, values
Facebook has been highly-rated by its employees for culture and values , coming in at No. 5 overall nationally in a new Glassdoor report . Twitter ...

Gay Family Values (@Depfox) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Gay Family Values @ Depfox ...

Common Lab Values on the App Store on iTunes
Get Common Lab Values on the App Store. See screenshots and ratings, and read customer reviews.

Tony Perkins' Remarks on Election 2012 and Values Voter Summit - YouTube
FRC's Tony Perkins to Discuss Presidential Race At National Press Club's Newsmakers Event September 23, 2011 WASHINGTON, D.C. - Family Research ...

Married Life: For parents, Ramadan is a time to think about values that are passed down
I worry that my 22-month-old baby will grow up thinking Ramadan is all about the food.

Forced marriages an 'assault on values': Scott Morrison
Immigration Minister Scott Morrison says forced marriages are an "assault on Australian values" after authorities intercepted a 14-year-old girl ...

America's values on trial with Manning
Over the past 2½ years, all of which he has spent in a military prison, much has been said about Bradley Manning, but nothing has been heard ...

Migrants must follow Australian values, says Frank Lowy
... boat person who became a shopping centre billionaire, has called on migrants to honour the ''great unwritten deal'' to follow Australian values ...

Resources last updated: 3/13/2016 10:30:37 AM