• 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: TID script object [was: coercing a list]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TID script object [was: coercing a list]


  • Subject: Re: TID script object [was: coercing a list]
  • From: Richard Morton <email@hidden>
  • Date: Fri, 31 Aug 2001 08:44:56 +1000

Ric Phillips's message of 30/8/01 9:32 AM contained:

>Where ever I use TIDs I put (or load) the following script object into my
>code, which makes them easier to use...less typing, one command to change
>them, one command to restore...

Cool! I played with this idea while back, to try to avoid having to
explicitly keep track of the old tids myself, but abandoned it (I think)
because it seemed to get a bit messy where tids are used a lot - say in
many handlers - within one script. I figured that I'd have to pass a
copy of the script object into each handler that required tids.


>...minimal error checking to catch type errors
>when using a variable.

A possible issue with only allowing a string is that this would error if
the caller tried to pass a value in the 'official' way - as a single item
list. Whilst this is practically irrelevant for the time being, the
default tids are actually: {""}

Also, something that was pointed out to me by the Great NG a while ago is
that the use of booleans in labelled parameter sub routines is actually
different between the call and the declaration. You have the following,
which is correct when calling the handler:

[to] setTID to c with saveOld

Whereas the recommended way for the declaration would be:

to setTID to c given saveOld:saveOld


These are totally basic but have saved me heaps of typing:

to initTids for newDelims
set oT to AppleScript's text item delimiters
set AppleScript's text item delimiters to newDelims
return oT
end initTids

to setTids for newDelims
set AppleScript's text item delimiters to newDelims
end setTids

As a side note for speed freaks, calling 'initTids' has some overhead,
like any sub routine. My testing here indicated that it approximately
doubles the time over changing tids in line. I found the same when using
this construct in line:

set {olTids, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, newDelims}

In other words, setting multiple values in one line also doubles the time
over setting them separately. Either way it's pretty irrelevant though.

Cheers,

Richard Morton
-- Great Lies of the Music Business: "Your mic is definitely on"


  • Prev by Date: Re: Scripting Newbie
  • Next by Date: Getting running status of an application
  • Previous by thread: Re: QuickTime and scripting transition effects
  • Next by thread: Getting running status of an application
  • Index(es):
    • Date
    • Thread