/PeO wrote:
> Just can't find out what's wrong
>
> Two examples in the included source, the first, "checkcmd" uses words for
the switch cases, the other uses strings..
>
> Also included is my addition to the switch function (but that itself is
not the one causing this problem)

Put 'reduce before your case block.

So instead of this:
        switch/default command [

    do this:
        switch/default command reduce [
            ; blah blah blah.

Why? The case block isn't evaluated, so words stay as words and don't refer
to their values. By evaluating the block, the word:
        RPL_WELCOME
    is replaced with it's value:
        "001"

Also, instead of this:
        RPL_WELCOME [
            print "welcome"
    this is easier:
        print switch/default command [
        RPL_WELCOME [
            "welcome"

And, for case sensitive switch, this is clearer:

SNA_switch: function [
 "Selects a choice and evaluates what follows it."
 value "Value to search for."
 cases [block!] "Block of cases to search."
 /default Default_Case "Default case if no others are found."
 /case "Value is case-sensitive."
 ][
 Refined_Select
 ][
 Refined_Select: to path! 'select
 if case [head insert tail :Refined_Select 'case]
 either value: Refined_Select cases value [
  do value
  ][
  either default [
   do case
   ][
   none
   ]
  ]
 ]

I hope that helps in some way.

Andrew Martin
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-

Reply via email to