Assignments to uncast dummy fields (was Re: simple
Kenneth Brody
kenbrody at bestweb.net
Fri Feb 15 19:31:16 PST 2008
Quoting Tyler (Fri, 15 Feb 2008 12:44:14 -0700):
> On Fri, Feb 15, 2008 at 12:18 PM, Kenneth Brody <kenbrody at bestweb.net> wrote:
>> Quoting Tyler (Fri, 15 Feb 2008 11:50:29 -0700):
[...]
>> > I would have thought the return value of a function would not have an
>> > explicit type.
>>
>> Are you saying that ADDMONTH() shouldn't return a date? Or that SQRT()
>> shouldn't return a number?
>
> Suppose it depends on your viewpoint. ADDMONTH and SQRT both take
> specific datatypes.
Not really, strictly speaking. They both treat their arguments as if they
were of an expected type, if they're not already, but strictly speaking,
they don't "take" specific arguments.
Consider SQRT("144"), which takes a literal of type (3,*), and returns
the number twelve as a (25,F) type.
Also, consider the ASC() function, which takes any type and returns the
ASCII value if that value's first character as a (4,.0) type, regardless
of the type passed to it.
> FIELDVAL, on the other hand, does not.
Yet its purpose is to retrieve a field's value, including the length and
type of that field.
The parameters input to a function are not necessarily related to the
type returned from that function.
> So no,
> *I* would not expect it to cast the return value to a specific type,
> especially as that action would seem to be performing operations that
> FIELDEDIT already does. The way I think, I would have called
> FIELDEDIT to explicitly cast if I wanted to conserve data type.
I assume you mean DOEDIT()?
> Returning a value of the same type as the FIELDVAL argument makes
> sense, just not what I was expecting - I would have thought it would
> be *,
Well, as I said, it returns the field, including length and type.
> or failing that that r eq "Y" would cast to the string literal
> since r has no explicitly defined type and the string literal does.
But r _does_ have a type -- (1,.0) -- at the time the comparison is
being done.
> I'm also used to Javascript and PHP, would have cast r to a string
> literal, not the string literal to the more restrictive numeric type.
So, if you assign a number to a variable without a type in those
languages, the number is converted to a string? Or if you compare
a number to a literal, it does a string compare?
--
KenBrody at BestWeb dot net spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com
More information about the Filepro-list
mailing list