Re: Re: Month as Integer (or he's ranting again)
Re: Re: Month as Integer (or he's ranting again)
- Subject: Re: Re: Month as Integer (or he's ranting again)
- From: Richard 23 <email@hidden>
- Date: Sun, 3 Dec 2000 07:31:16 -0800
>
From: "Marc K. Myers" <email@hidden>
>
>
Richard 23 wrote:
>
> Subject: Re: Month as Integer (or he's ranting again)
>
> Date: Fri, 1 Dec 2000 01:25:21 -0800
>
> From: Richard 23 <email@hidden>
>
> To: <email@hidden>
>
>
>
> on log theMsg
>
> continue log theMsg
>
> theMsg as list as item -- this allows me to label values
>
> -- for log messages, and strip the label before returning
>
> end log
>
What does the "as item" do in this construction? This whole redefinition
>
of "log" is a great idea and I want to understand it, but I get the same
>
results with "as item" or without it. I don't find "item" as a value
>
class in the AppleScript Language Guide, but the compiler accepts it as
>
a coercion so it must be a value class and not just an element of the
>
list value class. Or is it?
I use it for handlers which can process a single item or a list of items.
An easy visualization is a handler which returns the name of a file or
a list of files. If it takes a single argument, you can pass a single
item or a list of items. Calling it with a single item, one usually
doesn't want to get back a single-item list, one wants a single item.
That's what as item does in this case.
if the result is a list, it is unaffected and the list is returned.
If the result is a single-item list, the single item is returned without
the enclosing braces.
Stepping back, the as list is simply to strip off the record labels.
This allows queer inline log statements where the result isn't affected
(so long as you didn't want a record).
To really show it's usefulness in debugging would require more than is
tolerable in email so I'll give you a lousy example!
The thing to see here is that the result isn't mangled when using log:
----------
log {time:time string of (log {date:current date})}
display dialog "What's the time?" default answer result
set theTime to log {user:result's text returned}
EVENT LOG:
(*date:Sunday, December 3, 2000 6:58:35 AM*)
(*time:6:58:35 AM*)
(*user:7:15:00 AM*)
--> "7:15:00 AM"
the labels are used to make the log really clear and single item results
are returned as such although briefly wrapped up in a record for display.
* * * * * * * * * *
>
> 1. There's no such thing as a constant in AppleScript, although there
>
> are read only properties, of which the months are neither.
>
I don't understand this. There IS a value class "Constant" defined in
>
the Language Guide. If they're not constants, what are those annoying
>
things the Language Guide refers to as "constants" and which won't
>
coerce into strings? (months, days of the week, true, false, yes, no,
>
ask, etc.) Is there some difference in this regard between AS 1.1.2
>
(which I'm using) and the more recent versions?
Yes there is a constant class, but I don't know of any off hand that
really function that way. I guess I'm referring to AppleScript's
constants. Since I can set tab to "<tab>" and it stays that way, and
I can set PI to 5141.3 and it sticks, they don't seem like constants
to me!
>
I'm finding this discussion to be fascinating!
See the ridiculous pi example next... You might change your mind! 8)
R23