• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is a-b not equal to ((source of a) -b) ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is a-b not equal to ((source of a) -b) ?


  • Subject: Re: Why is a-b not equal to ((source of a) -b) ?
  • From: bill fancher <email@hidden>
  • Date: Tue, 3 Sep 2002 22:56:36 -0700

On Tuesday, September 3, 2002, at 02:01 PM, email@hidden wrote:

On Tue, 3 Sep 2002 11:46:18 -0700, bill fancher <email@hidden>
asked,

How come subtracting a large number from the result of getmillisec
(an
osax call under X 10.2) seems not to do the subtraction?
GetMilliSec -ms2
-->7.9489387E+7
--> (when it should be about "7" or similar small number

Well, Finder "has no idea how to get milliseconds" either, but it does
so anyways. No reason a number couldn't do the same thing. I thought it
was perhaps being interpreted as

tell someNumber
GetMilliSec
end tell

but testing reveals that that gets a runtime error (though one might
argue that it SHOULD work, just like "tell {{a:1,b:2,c:3}} to items
whose a is 1" SHOULD work).

To convince yourself that GetMilliSeconds will eat what follows as a
"parameter" of some sort, though, try:

GetMilliSec "spud"

That isn't limited to GetMilliSec. If you've got Jon's commands, try:

the ticks {1, 2, 3}

The base cause of the behavior is that

GetMilliSec -var1

is being parsed as

GetMilliSec of (-var1)

meaning "Send the GetMilliSec message with a direct parameter of the value of
(-var1)"

Just put parentheses in to make the order correct:

(GetMilliSec) - var1

Sure, that's what I first suggested (it got snipped above). But the base cause of the puzzlement expressed in the original question is, I believe, that GetMilliSec doesn't take a direct parameter, while AS happily sends one (that gets ignored). I should have let it go at that.


Now, is 'GetMilliSec of (expr)' the same as 'tell (expr) to GetMilliSec'? No,
because the first gives a result, while the second says "(expr) doesn't
understand the GetMilliSec message."

As I noted above (though I said "gets a runtime error")...

Fundamentally, in parsing the first form,
AppleScript sees the name of a handler (from an osax or a handler defined in the
script), and so it looks for "of" or an implicit "of" to flag a direct object.
In the "tell" form, there is no possibility for a direct object, and so you get
the message "GetMilliSec of nothing" sent to (expr), which responds with the
error. So,

GetMilliSec of -var1

means

target: AppleScript, handler GetMilliSec, object -var1

while

tell -var1 to GetMilliSec

means

target: -var1, handler: GetMilliSec, object: nothing

It's not so *quite* so clear cut. E.g. this (in a tell app "Hypercard" block):

tell stack "FPDirectory" to close

generates

core\clos{ ----:obj { form:'name', want:'cSTK', seld:"FPDirectory", from:'null'() }, &subj:obj { form:'name', want:'cSTK', seld:"FPDirectory", from:'null'() }, &csig:65536 }

Notice that the stack has slipped from being the "target" of the tell to being the direct object of event (AND the "subject").

I had originally (wrongly) thought something similar might be happening here and thought I'd clearly acknowledged that I was not correct in thinking that: "I thought... but testing reveals...".

I don't think we really disagree on anything here, though I do seem to have expressed myself poorly. Apologies for that.

--
bill
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Why is a-b not equal to ((source of a) -b) ? (From: email@hidden)

  • Prev by Date: Perl "success"
  • Next by Date: Jaguar Idle Handler Strangeness
  • Previous by thread: Re: Why is a-b not equal to ((source of a) -b) ?
  • Next by thread: Re: Why is a-b not equal to ((source of a) -b) ?
  • Index(es):
    • Date
    • Thread