HI All,
Would appreciate a lending hand here.
I am trying to read a dropped folder for items in it, reading each item if delimited by linefeed or carriage return, then storing the item’s name accordingly in a list. Below is the handler that I use:
on read_nameFromTexfileDoc()
try
set fileDoc to choose file with prompt "LOCATE YOUR TEXTFILE"
set lf to ASCII character 10
set rf to ASCII character 13
--read the file first to check line delimiter (line feed or return??)
set test_delim to read fileDoc
set list_textNames to {}
set file_Ref to (open for access fileDoc)
try
if test_delim contains lf then
set thisName to read file_Ref using delimiter lf
copy thisName to list_textNames
else if test_delim contains rf then
set thisName to read file_Ref using delimiter rf
copy thisName to list_textNames
end if
close access file_Ref
on error
close access file_Ref
display dialog return & "Error in reading the text file." with icon 0 buttons "OK" default button 1
end try
end try
set fileCount to count of list_textNames
return (fileCount)
end read_nameFromTexfileDoc
When all items in the folder is delimited by carriage return, the count of file items is correct. However, when some items are delimited by linefeed, this count always takes only those delimited by linefeed.
I tried several workarounds but I can’t seem to get the count right. How can I get this count right? I know there’s something wrong with it but I just cannot find it.
Thanks for the help.
archseed