Reputation: 11
Third party software, lets name it 3RD has embedded TCL
.
Some function in 3RD execute TCL or create TCL objects
. During execution generate several commands (events?) in specific order, e.g.:
For each command\event are also created new variables or existing vars change their state. Commands names above are not fully known for user. I guess each command invoked in 3RD, send package with set of TCL objects (commands, procs, events, variables) to use by end user (me). Then I can write sript calling each of command\event created by 3RD.
My question is: am I able to get these commands\events names in their order?
info commands
or info procs
don't give that possibility
Upvotes: 0
Views: 65
Reputation: 137567
If you want to keep things in a specific order, you put them in a list or dictionary (dictionaries preserve order of first creation of a key). A list is probably the most convenient option when you are working in C (or C++) as you can pass the flags TCL_APPEND_VALUE | TCL_LIST_ELEMENT
to Tcl_SetVar2Ex()
to get an lappend
.
If the C code doesn't suggest an order of names of things, you have to build that list in Tcl, maybe with lappend
or list
. I'm not sure what the criteria are for how to decide what order to put things in are (other than that you have an ...Init and ...Start at the beginning and an ...Out at the end); I literally do not know your problem space.
Once you have a list, you can literally do this:
foreach cmd $theList {
$cmd; # In this case, you don't need eval for just command names
}
Things can get a bit more complicated if you want to pass varying extra arguments. Or a lot more complicated. We'll need more information to help effectively.
Upvotes: 1