TIDs Inquiry
TIDs Inquiry
- Subject: TIDs Inquiry
- From: David <email@hidden>
- Date: Sun, 10 Nov 2002 13:38:51 -0600
When reading a text file from an AppleScript within Script Editor that
is a list of items return delimited such as a series files to back-up
or mail boxes for mail to execute a script on; I consistently run into
a problem where the AppleScript Text Items command does not seem to
work as expected.
A text file that is read in with the below code seems not to work with
the TIDs as expected while a string pasted into an AppleScript variable
manually seems to work as expected.
on readFile(file_path)
try
open for access file file_path without write permission
set the_retrieved_info to read file (file_path)
close access file file_path
return the_retrieved_info
on error
close access file file_path
return 0
end try
end readFile
on getTextItems(str, aDelim)
set savedTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to aDelim
set textItemsList to text items of str
set AppleScript's text item delimiters to savedTextItemDelimiters
return textItemsList
end getTextItems
For example:
data that is read from a .txt file made by TextEdit using System Mac OS
10.2.1
Example a)
a
b
c
d
Example b)
a,b,c,d
Example a would show a 1 item list while example b would appear as a
four item list. Am I correct in assuming that example a *should* show
up as a four item list? As I mentioned earlier, if example a was pasted
into a variable the result would also match the behavior that I have
described for example b.
Sure it would be easier to simply write the file with commas but then I
do not learn what is wrong here and I get a file that is a pain to
manually modify.
thanks!
********************************************
David Dittmann
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.