But can't you just add the YesNoValue function to your switch?

like this:

switch (yesnovalue(target)) {
   case "Yes":
      value = True;
      break;
   case "No":
      value = False;
      break;
}

-----Original Message-----
From: Patricia G.L.Hall [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 23, 2003 12:33 PM
To: CF-Talk
Subject: Re: Switch:Case Differs in CFMX from CF5?

That sounds about right.  I'll test, but I'm pretty sure it is the case.

As to your suggested resolution:  I'll have to rewrite the script to
use if/else since the point of the udf IS to resolve the differences of
"target".  I have to work with existing data and sometimes I'll get Y,
yes 1, etc... so I wanted this function to do that work for me.  Ah
well.  If/Else it is.

-Patti

On Wednesday, October 22, 2003, at 05:08  PM, J E VanOver wrote:

> I would guess then that it is the SPECIFIC values you are using -- "Y",
> "YES" and true
>
> It sounds like MX - with stronger variable typing - is resoving the
> "Y" and
> "YES" strings and the keyword "true" to the value "1.0"
>
> Try resolving the differences in "target" before using it in the SWITCH
> statement.  The YesNoFormat() function does this nicely for you, then
> just
> check for "YES" or "NO"  This function is backward compatible too.
>
> Jevo
> -----Original Message-----
> From: Patricia G. L. Hall [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 22, 2003 8:29 AM
> To: CF-Talk
> Subject: Switch:Case Differs in CFMX from CF5?
>
> ... generic example trimmed ...
> I have run this syntax in CF5 successfully.  Just now I tried the same
> on
> a box with CFMX 6.1 and I get this error:
>
> Context validation error for tag CFCASE.
> The CFSWITCH has a duplicate CFCASE for value "1.0".
>
> FYI, here is the specifc code I was running:
>
> function convertBooleanOrNull(target) {
> var value = "NULL";
> switch (target) {
> case "Y":
> case "Yes":
> case true:
> value = True;
> break;
> case "N":
> case "No":
> case false:
> value = False;
> break;
> }
> return value;
> }
>
>
<image.tiff>
>
>


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to