Sujet : Re: misunderstaning of switch command
De : heller (at) *nospam* deepsoft.com (Robert Heller)
Groupes : comp.lang.tclDate : 24. Jun 2025, 13:37:28
Autres entêtes
Organisation : Deepwoods Software
Message-ID : <103e668$20vvo$1@dont-email.me>
References : 1
User-Agent : TkNews 3.0 (1.2.20)
At Tue, 24 Jun 2025 08:23:45 -0000 (UTC) Mark Summerfield <
m.n.summerfield@gmail.com> wrote:
I have a switch command which is doing something I don't expect but I
don't understand what I've done wrong. In this example the default is
always executed but I expect the case before that to be executed.
const UNCOMPRESSED U
const ZLIB_COMPRESSED Z
const SAME_AS_PREV > set filename somefile.txt
set action "added"
set kind Z
switch $kind {
$::SAME_AS_PREV { puts "unchanged \"$filename\"" }
$::UNCOMPRESSED { puts "$action \"$filename\"" }
$::ZLIB_COMPRESSED { puts "$action \"$filename\" (zlib
compressed)" }
default { puts "!!!!!!!! UNEXPECTED !!!!!!!!" }
}
What am I doing wrong?
switch does NOT evaluate the case labels. That is, the case labels are
*literally*:
{$::SAME_AS_PREV}, {$::UNCOMPRESSED}, {$::ZLIB_COMPRESSED}
-- Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364Deepwoods Software -- Custom Software Serviceshttp://www.deepsoft.com/ -- Linux Administration Servicesheller@deepsoft.com -- Webhosting Services