TIA.
extra switch pattern with no body
extra switch pattern with no body
while executing
"switch -exact -- $wdc {
1 {set wdc SCN_MODE} ;# Scan mode
2 {set wdc SVC_MODE} ;#Service Search mode
3 {set wdc CTM_MODE} ;#Custom Search mode
4 {set ..."
(procedure "jpm_mode" line 7)
invoked from within
"jpm_mode 1 0"
(menu invoke)
switch -exact -- $wdc {
1 {set wdc SCN_MODE} ;# Scan mode
2 {set wdc SVC_MODE} ;#Service Search mode
3 {set wdc CTM_MODE} ;#Custom Search mode
4 {set wdc CC_MODE} ;# Close Call Only mode
5 {set wdc WX_MODE} ;# WX SCAN mode
6 {set wdc FTO_MODE} ;# Tone-Out mode
}
switch -exact -- $wdd {
1 {set wdd BLAH}
etc etc...
}
--
Best Regards, Keith
http://home.comcast.net/~kilowattradio/
Tired of Google Groups?
http://home.comcast.net/~kilowattradio/usenet.html
I cannot check at the moment, but I suspect if you move the comments
inside the switch bodies, you'll be fine. Remember switch takes a list
of pattern body, comments only make sense in the bodies themselves,
otherwise I suspect they are interpreted as patterns and bodies and
luckily you ended up with an odd number of list elements.
Mark
take your "comments" out of the swith block - they aren't
what you think they are. move the comments *inside* the
execution blocks themselves to document what each are doing
>
> switch -exact -- $wdc {
> 1 {set wdc SCN_MODE} ;# Scan mode
> 2 {set wdc SVC_MODE} ;#Service Search mode
> 3 {set wdc CTM_MODE} ;#Custom Search mode
> 4 {set wdc CC_MODE} ;# Close Call Only mode
> 5 {set wdc WX_MODE} ;# WX SCAN mode
> 6 {set wdc FTO_MODE} ;# Tone-Out mode
> }
details of what the swith command "sees"
pattern 1 = 1
action 1 = set wdc SCN_MODE
pattern 2 = ;#
action 2 = Scan
pattern 3 = mode
action 3 = 2
pattern 4 = set wdc SVC_MODE
action 4 = ;#Service
etc.
comments are only comments if they are where the interp expects
to see a command not within the arguments of a command
Side not - instead of a switch, a simple lookup
array would be (imho) easier
# Once at init time
array set ModeLookup {
1 SCN_MODE
2 SVC_MODE
3 CTM_MODE
4 CC_MODE
5 WX_MODE
6 FTO_MODE
}
#then in place of your switch..
set wdc $::ModeLookup($wdc)
Bruce
Now look at what
llength {
1 {set wdc SCN_MODE} ;# Scan mode
2 {set wdc SVC_MODE} ;#Service Search mode
3 {set wdc CTM_MODE} ;#Custom Search mode
4 {set wdc CC_MODE} ;# Close Call Only mode
5 {set wdc WX_MODE} ;# WX SCAN mode
6 {set wdc FTO_MODE} ;# Tone-Out mode
}
--> 33 tells you ;-(
compare to:
llength {
1 {set wdc SCN_MODE ;# Scan mode }
2 {set wdc SVC_MODE ;#Service Search mode }
3 {set wdc CTM_MODE ;#Custom Search mode }
4 {set wdc CC_MODE ;# Close Call Only mode }
5 {set wdc WX_MODE ;# WX SCAN mode }
6 {set wdc FTO_MODE ;# Tone-Out mode }
}
--> 12 ;-)
uwe
>
> For some reason switch is complaining about extra switch pattern.
> I have tried with -glob option with the same results.
>
> TIA.
>
>
> extra switch pattern with no body
> extra switch pattern with no body
> while executing
> "switch -exact -- $wdc {
> 1 {set wdc SCN_MODE} ;# Scan mode
> 2 {set wdc SVC_MODE} ;#Service Search mode
> 3 {set wdc CTM_MODE} ;#Custom Search mode
> 4 {set ..."
> (procedure "jpm_mode" line 7)
> invoked from within
> "jpm_mode 1 0"
> (menu invoke)
>
> switch -exact -- $wdc {
> 1 {set wdc SCN_MODE} ;# Scan mode
> 2 {set wdc SVC_MODE} ;#Service Search mode
> 3 {set wdc CTM_MODE} ;#Custom Search mode
> 4 {set wdc CC_MODE} ;# Close Call Only mode
> 5 {set wdc WX_MODE} ;# WX SCAN mode
> 6 {set wdc FTO_MODE} ;# Tone-Out mode
> }
The comments is in the wrong place.
Look at this code:
switch -exact -- $wdc {
1 {set wdc SCN_MODE}
;# Scan
mode 2
{set wdc SVC_MODE} ;#Service
Search mode
3 {set wdc CTM_MODE}
;#Custom Search
mode 4
{set wdc CC_MODE} ;#
Close Call
Only mode
5 {set wdc WX_MODE}
;# WX
SCAN mode
6 {set wdc FTO_MODE}
;# Tone-Out
mode
}
Your switch cases are:
1, ;#, mode, {set wdc SVC_MODE}, Search, 3, ;#Custom, mode, {set wdc
CC_MODE}, Close, Only, 5, ;#, SCAN, 6, ;#, and mode (this last one with
out a script!)
This is how you should format things:
switch -exact -- $wdc {
1 {set wdc SCN_MODE ;# Scan mode
}
2 {set wdc SVC_MODE ;#Service Search mode
}
3 {set wdc CTM_MODE ;#Custom Search mode
}
4 {set wdc CC_MODE ;# Close Call Only mode
}
5 {set wdc WX_MODE ;# WX SCAN mode
}
6 {set wdc FTO_MODE ;# Tone-Out mode
}
}
The comments *have* to be inside the scripts. DON'T put them "outside"
the scripts, since they won't be seen as comments. Tcl comment syntax
is not like C/C++ or FORTRAN comment syntax. Tcl's lexical analyzer
does not 'strip' comments off as a pre-processing step and there is NO
*sematic* parser in Tcl (in the same sense as true compiled languages
has them). The switch *command* (DON'T think of it as a 'statement')
takes an even element *LIST* as its last argument (or an even number of
arguments after the options and switch clause). This is *just a list*,
where the 1st, 3rd, 5th, etc. elements are your cases, and the 2nd, 4th,
6th, etc. elements are scripts that are passed to uplevel, depending on
which case matched. These *scripts* can contain comments, but you
cannot include comments in the argument *LIST*, since the switch
*command* does not parse them out (it does no parsing itself).
>
> switch -exact -- $wdd {
> 1 {set wdd BLAH}
> etc etc...
> }
--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
hel...@deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/
Does this answer your question?
same link, shortened: