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

The set name does not work

69 views
Skip to first unread message

Andre

unread,
Jan 14, 2018, 10:52:49 PM1/14/18
to
Hi,

Why my script doesn’t work. The script below:

set number1 { 324 245553 334 443}
set name “$number1”
set joinnumber [join $name “”] ;#cannot join the numbers..

thanks

Gerald Lester

unread,
Jan 14, 2018, 11:10:45 PM1/14/18
to
On 01/14/2018 09:52 PM, Andre wrote:
> set number1 { 324 245553 334 443}
> set name “$number1”
> set joinnumber [join $name “”] ;#cannot join the numbers..

But the following does:
set number1 { 324 245553 334 443}
set name "$number1"
set joinnumber [join $name ""]

-- moral of the story, use a text editor when programming and not a word
processor!

BTW, this also works:
set number1 { 324 245553 334 443}
set name $number1
set joinnumber [join $name {}]


--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Arjen Markus

unread,
Jan 15, 2018, 2:54:41 AM1/15/18
to
On Monday, January 15, 2018 at 5:10:45 AM UTC+1, Gerald Lester wrote:
> On 01/14/2018 09:52 PM, Andre wrote:
> > set number1 { 324 245553 334 443}
> > set name “$number1”
> > set joinnumber [join $name “”] ;#cannot join the numbers..
>
> But the following does:
> set number1 { 324 245553 334 443}
> set name "$number1"
> set joinnumber [join $name ""]
>
> -- moral of the story, use a text editor when programming and not a word
> processor!
>
What Gerald means is that word processors try to be helpful and insert all manner of characters like the "smart" quotes above that may look like ordinary quotes but really are an entirely different thing. So indeed: use a text editor!

Regards,

Arjen

Andre

unread,
Jan 15, 2018, 7:07:52 AM1/15/18
to
Sorry Gerald, I am has wrong type :). Below the script:

set a1 {272 373282 39383383}
set b 1
set c [join a$b {}] ;#doesnt work (the result is incorrect)

Thanks

Brad Lanam

unread,
Jan 15, 2018, 8:25:01 AM1/15/18
to
[join a$b {}] does not reference a variable.
The naive attempt would be something like
[join $a$b {}] or [join ${a$b} {}]. These
are incorrect, there is no double evaluation of
a command.

Use: [join [set a$b] {}]

Gerald Lester

unread,
Jan 15, 2018, 9:48:23 AM1/15/18
to
Also, OP are attempting to go down a bad road, use arrays and indexes
instead:

set a(1) {272 373282 39383383}
set b 1
set c [join $a($b) {}]

Ricardo kozmate.net

unread,
Jan 16, 2018, 5:03:26 AM1/16/18
to
Em 15/01/18 12:07, Andre escreveu:
> set c [join a$b {}] ;#doesnt work (the result is incorrect)

Also, I'd say the result was not "incorrect", the result was "unexpected".

That is, you better include what you expected the result to be, rather
simply "doesn't work". In this case it was easy to guess but it is not
always so.

--
{ricardo from kozmate.net}
0 new messages