• 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: email@hidden
  • Date: Tue, 3 Sep 2002 17:01:07 -0400

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

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." 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

--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Why is a-b not equal to ((source of a) -b) ?
      • From: bill fancher <email@hidden>
  • Prev by Date: Re: Scripting Jaguar mail app
  • Next by Date: Help! Need to get text from OS X Mail to Tex-Edit...
  • 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