Re: Difference between $foo and [set foo]
- From: Kaitzschu <kaitzschu@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Jun 2005 22:23:49 +0300
On Tue, 7 Jun 2005, Hans Herrmann wrote:
Hi, last time you helped me with a problem:
###################
set a 1,0 set b 2,0 foreach pos {a b} { regsub -all {,} [set $pos] {.} [set pos] }
######################
Why i must not do "$$pos" or "[eval puts $pos]" and for the seconde substitution "$pos".
I don't quite understand what you mean with all that (especially that [eval puts $pos] lost me), but I think you get a clue when you read what [regsub] takes as parameters:
regsub ?switches? expr value repl varname
As pos goes through a and b you must feed a value to regsub ([set $pos] translates to [set a] and [set b], giving out correct values) and then you must provide some variable where to store substituted string ([set pos] goes to a and b).
But otherwise, there is no difference between '$foo' and 'set foo'. Except that latter is longer.
I'm not a specialist in programming, I'm a "hobby-tcler"
So am I :) Sorry to bother if that didn't help.
--
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done
.- References:
- Difference between $foo and [set foo]
- From: Hans Herrmann
- Difference between $foo and [set foo]
- Prev by Date: BLT for acrivetcl8.5.0.0b3
- Next by Date: Re: Difference between $foo and [set foo]
- Previous by thread: Difference between $foo and [set foo]
- Next by thread: Re: Difference between $foo and [set foo]
- Index(es):