Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is this possible ?

3 views
Skip to first unread message

Eric

unread,
Feb 1, 2003, 12:43:11 AM2/1/03
to
is something like this possible in tcl ...

set dataList { {eval echo "my command"} dataItem1 dataItem2.....}

foreach data $dataList {
$dataList
}

knowing that that dataItem1 dataItem2 .... are all commands and that echo is
a command that needs to evalutaed... can you just use $dataList to get it to
run the eval command or how could you accomplish something like this?

Eric :D


Marco Maggi

unread,
Feb 1, 2003, 3:32:03 AM2/1/03
to

"Eric" wrote:
>is something like this possible in tcl ...
>
>set dataList { {eval echo "my command"} dataItem1 dataItem2.....}
>
>foreach data $dataList {
> $dataList
>}


lappend lst [list puts one]
lappend lst [list puts two]
lappend lst [list puts three]

foreach script $lst {
eval $script
}

Embedding the [eval] in $script is a bad idea.

Ciao,
Marco

--
"Love & Peace" -- Vash the Stampede

Eric

unread,
Feb 1, 2003, 8:55:09 AM2/1/03
to

"Marco Maggi" <ma...@maggi.luna> wrote in message
news:878yx07...@bolt.moon...


With this though it will eval all one two and three commands .. i just would
like one of the list commands to be evaluated and the rest to be executed.
:)


Marco Maggi

unread,
Feb 1, 2003, 12:39:32 PM2/1/03
to

"Eric" wrote:
>With this though it will eval all one two and three commands
>.. i just would like one of the list commands to be
>evaluated and the rest to be executed.

Executed like in "execute an external command" ? If so:

lappend lst $script_that_when_evaluated_returns_a_command
lappend lst $command_arg1 $command_arg2 $command_arg3

set command [namespace eval :: [lindex $lst 0]]
eval exec $command [lrange $lst 1 end]

example:

lappend lst {auto_execok ls}
lappend lst --size --kilobytes

set command [namespace eval :: [lindex $lst 0]]
set result [eval exec $command [lrange $lst 1 end]]

TCL evaluates scripts the global namespace.

Darren New

unread,
Feb 12, 2003, 1:30:30 PM2/12/03
to
Eric wrote:
> is something like this possible in tcl ...

Yep. Isn't Tcl fun? :-) Just follow the rules on Tcl.n and it works.


0 new messages