Raymond E. Griffith wrote:
> I think you may have hit upon a bug.
I don't think so. That seems like expected behaviour to me.
> I put the following into the message box:
>
> answer value("This is my dog.")
>
> and it returned a "double binary operator" and flagged the
> word "is" as a bad token. Evidently it was trying to evaluate
> the trueness or falseness of the expression containing "is".
Well, the error message is a little less than user friendly, but value
attempts to evaluate its arguments as a Metacard expression. So of
course it tries to compare "This" with "my dog".
I'm not sure why it fails instead of returning false. I suspect it may
have something to do with missing quotes around each substring.
> However, you would think that the value of a
> string would be the string.
Then what is value("1+1")? Should it be the string "1+1"? Or the
expected result of 2?
The value of a string being the same string pretty much defeats the
purpose of having a value function. Why do you need a function that does
nothing?
> However, I tried
>
> answer value(quote & "This is my dog." & quote)
>
> and it returned
>
> This is my dog.
Sounds right to me.
Think of value() as stripping a single pair of quotes from a string and
treating the result as a Metacard expression. Then:
value(quote & "green_eggs and ham" & quote)
will return the string "green_eggs and ham", but
value("green_eggs and ham")
will attempt to evaluate the variable green_eggs and do a Boolean AND
with the variable ham.
> I admit I like HC's easy way of handling strings. However,
> even it is a bit arbitrary. For example, in HC
>
> answer value(3 = 2+1)
>
> and
>
> answer value("3 = 2+1")
>
> both return
>
> true
>
> even though I hoped to get a string back for the second.
Why say
answer value("3 = 2+1")
when all you really need is
answer "3 = 2+1"
?
--
Steven D'Aprano
==========================================
M.B. Sales Pty Ltd Ph: +61 3 9460-5244
A.C.N. 005-964-796 Fax: +61 3 9462-1161
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.