• 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
TIDS are? - a script for displaying the current value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TIDS are? - a script for displaying the current value


  • Subject: TIDS are? - a script for displaying the current value
  • From: Richard Morton <email@hidden>
  • Date: Fri, 31 Aug 2001 14:14:28 +1000

Here is a script I use sometimes during debugging to tell me what the
TIDS are actually set to. I wrote it to use in Script Editor via the OSA
Menu, but it doesn't work that way here, so I just open the script & run
it as necessary.

It displays a dialog showing the literal value. If the tids are anything
other than one of what I call the 'loose default' values - {""}, "", {} -
the dialog also shows the ASCII number(s) of the character(s). If tids
are anything other than the strict default, the dialog offers to reset
them. It wasn't written for public consumption, so no guarantees of
functionality or clarity. :-}

It's worth noting that simply running the line 'AppleScript's text item
delimiters' in your editor and observing the result is as good or better
than running this, except that you don't get the ASCII value directly.

Beware of line breaks, Server Mangulation(TM), and losing track of your
towel...

-- -- TIDS are? -- -- by Richard Morton 2001 -- --
set currentTIDS to AppleScript's text item delimiters
try
set {defString, mainString, endString} to {" (default setting)", "", ""}

if currentTIDS is {""} then
set endString to defString
else if currentTIDS is "" then
set endString to " (empty string)"
end if

set haveBrackets to (class of currentTIDS is list) -- brackets?
if haveBrackets then try
set currentTIDS to item 1 of currentTIDS -- ignore any further
delimiters, as TIDS do
on error
set endString to " (empty list)"
end try
set haveQuotes to (class of currentTIDS is string) -- quotes?

copy currentTIDS to mainString
if haveQuotes then set mainString to "\"" & mainString & "\""
if haveBrackets then set mainString to "{" & mainString & "}"
if endString is "" then
set tidString to currentTIDS as string -- coerce any numeric or other
values
set n to length of tidString
repeat with I from 1 to n
set endString to endString & (ASCII number (item I of tidString))
if I is not n and n is not 1 then set endString to endString & ", "
end repeat
if endString is not "" then set endString to return & "ASCII: " &
endString
end if

if endString contains defString then
set bList to {"OK"}
else
set bList to {"Cancel", "Reset"}
end if

set b to button returned of (display dialog "TIDS are: " & mainString &
endString buttons bList default button (last item of bList) with icon 1)
if b = "Reset" then set AppleScript's text item delimiters to {""}
on error number n
set AppleScript's text item delimiters to currentTIDS
if n does not equal -128 then error "Aaarrgh! " & n
end try
-- --


Cheers,

Richard Morton
-- Great Lies of the Music Business: "It sounds great at the back of
the hall"


  • Prev by Date: Re: Getting running status of an application
  • Next by Date: Strictly speaking (was: coercing a list)
  • Previous by thread: Re: Quirk coercing aliases to strings
  • Next by thread: Strictly speaking (was: coercing a list)
  • Index(es):
    • Date
    • Thread