[REBOL] Re: How can one use named constants in switch?
From: dlhawley:home at: 25-Oct-2001 10:54
Thanks for the great replies everybody. Now I have another question: Is there
a way to pass data into predefined cases?
cases: reduce [
ca [print ["five:" msg]]
cb [print ["eight:" msg]]
]
switch first msg cases
This isn't that big of a deal since I don't really have to predefine the cases...
but I figure that I'll learn more re REBOL
Dave
Previously, you (Cyphre) wrote:
> Hi David,
>
> try this:
>
> ca: 5
> cd: 8
> i: first random [5 8]
>
> switch i reduce [
> ca [print "five"]
> cb [print "eight"]
> ]
>
> regards,
>
> Cyphre
>
> ----- Original Message -----
> From: "David Hawley" <[dlhawley--Home--Com]>
> To: <[rebol-list--rebol--com]>
> Sent: Thursday, October 25, 2001 6:33 AM
> Subject: [REBOL] How can one use named constants in switch?
>
> > I just spent a while trying to figure out why the following fails:
> >
> > case_a: 1
> > case_b: 2
> >
> > msgType: getMsg ... ; integer!
> >
> > switch msgType [
> > case_a [ msgA ]
> > ...
> > ]
> >
> > this fails since the cases are variables not constants (from a C
> perspective
> > where case_X would be an enum or #define). Is there any way to write this
> except
> >
> > switch msgType [
> > 1 [ msgA ]
> > ...
> > ]
> >
> > ? Thanks,
> > Dave
> >
> > --
> > David L. Hawley D.L. Hawley and Associates 1.503.274.2242
> > Software Engineer [David--L--Hawley--computer--org]
> >
> > --
> > To unsubscribe from this list, please send an email to
> > [rebol-request--rebol--com] with "unsubscribe" in the
> > subject, without the quotes.
> >
> >
>
> ---
> Odchozí zpráva neobsahuje viry.
> Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz).
> Verze: 6.0.282 / Virová báze: 150 - datum vydání: 25.9.2001
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
>
--
David L. Hawley D.L. Hawley and Associates 1.503.274.2242
Software Engineer [David--L--Hawley--computer--org]