TIDs info summary
TIDs info summary
- Subject: TIDs info summary
- From: Paul Skinner <email@hidden>
- Date: Fri, 8 Nov 2002 14:05:41 -0500
I find only six separate entries in the ASLG on the text item
delimiter property of the global variable applescript. Little enough
that I can post it all here for those without a copy or motivation.
The last four are index or appendix entries and the one of those on
p.379 is just a summary of the main entry on p.210-211.
Some statements pertinent to the ongoing discussions...
1. ASLG p.70:This property defaults to an empty string.
( try to get the ascii number of the default contents of the TIDs )
2. ASLG p.210:You may want to use an error handler to reset the Text
Item Delimiters property to its former value if an error occurs.
( In several places it is suggested that one reset the TIDs after
changing them. Only in the most simplified example scripts are they
changed and not reset. )
3. ( my own ) Storing and restoring the TIDs is pointless if you
specifically set them before each use. UNLESS you use handlers or
loaded scripts or run script constructions. If you use any of these
language features then it becomes important to store and restore the
current TIDs within them in order to prevent these constructions from
invisibly and perhaps unexpectedly altering the TIDs and generating
unexpected results in the main script. I don't think that anyone here
has suggested that this is not the case. Not even Bill with his
rebelious TIDs scofflaw ways.
ASLG on TIDs
p.379 Appendix
The Text Item Delimiters property, which is the only property you can
get and set using the global variable AppleScript, consists of a list
of the delimiters used by AppleScript when coercing lists to strings
and when getting text items from strings. This property is declared by
AppleScript and is available from any script. You can get and set this
property with statements such as the following:
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
get last text item of "Hard Disk:CD Contents:Release Notes"
--result: "Release Notes"
set AppleScript's text item delimiters to savedDelimiters
Currently, only the first delimiter in the list is used by AppleScript.
For more information, see AppleScript Properties (page 210).
p.70
AppleScript also supports coercion of an entire list to a string if all
items in the list can be coerced to a string. The resulting string
concatenates all the items, separated by the current value of the
AppleScript property Text Item Delimiters. This property defaults to an
empty string, so the items are simply concatenated. For more
information on Text Item Delimiters, see AppleScript Properties (page
210).
p.199
AppleScript Properties (page 210) describes global properties of
AppleScript, which you can use in any script. Some properties act as
constants, but you can modify AppleScripts Text Item Delimiters, which
AppleScript uses in performing various string operations.
p.210-211
AppleScript Properties
You can use the global variable AppleScript to get properties of
AppleScript itself rather than properties of the current target. You
can refer to this global variable from any part of any script.
AppleScript provides the following global properties you can use as
constants: pi, return, space, tab, and version. These values are
described in Arithmetic Constants (page 101), String Constants (page
105), and RVersion ConstantS (page 106). You should not attempt to
change the values for these constants.
The Text Item Delimiters property consists of a list of strings used as
delimiters by AppleScript when it coerces lists to strings or gets text
items from strings. AppleScript currently uses only the first delimiter
in the list. You can get and set the current value of AppleScripts
Text Item Delimiters. Normally, AppleScript doesnt use any delimiters.
For example, if AppleScripts text delimiters have not been explicitly
changed. the script
{"bread", "milk", "butter", 10.45} as string
returns the following result:
"breadmilkbutter10.45"
For printing or display purposes, it is usually preferable to set the
text delimiters to something thats easier to read. For example, the
script
set AppleScript's text item delimiters to {", "}
{"bread", "milk", "butter", 10.45} as string
returns this result:
"bread, milk, butter, 10.45"
The Text Item Delimiters property also allows you to extract individual
names from a pathname. For example, the script
set AppleScript's text item delimiters to {":"}
get last text item of "Hard Disk:CD Contents:Release Notes"
returns the result "Release Notes".
If you change the Text Items Delimiters property in the Script Editor,
it remains changed until you restore its previous value or until you
quit the Script Editor and launch it again. If you change the Text
Items Delimiters in a script application, it remains changed in that
application until you restore its previous value or until the script
application quits; however, the delimiters are not changed in the
Script Editor or in other script applications you run.
You may want to use an error handler to reset the Text Item Delimiters
property to its former value if an error occurs. For more information
on handling errors, see Try Statements (page 259).
set savedTextItemDelimiters to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {"**"}
--other script statements...
--finally, reset the text item delimiters:
set AppleScript's text item delimiters to savedTextItemDelimiters
on error m number n from f to t partial result p
--also reset text item delimiters in case of an error:
set AppleScript's text item delimiters to savedTextItemDelimiters
--and resignal the error:
error m number n from f to t partial result p
end try
p.353 Appendix
Changing Text Item Delimiters AppleScript Properties (page 210)
p.405 Index
Text Item Delimiters property 210211
p.414 Index
Text Item Delimiters property of AppleScript 210211
--
Paul Skinner
_______________________________________________
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.