Open or what (was Re: Close Access)
Open or what (was Re: Close Access)
- Subject: Open or what (was Re: Close Access)
- From: John McAdams <email@hidden>
- Date: Mon, 28 Jan 2002 23:46:35 -0500
Thank you Mr Bates for keeping the thread alive. I was going to let it
go but...Further experimentation has yielded the following nuggets of AS
wisdom (tongue is in cheek). It seems AS will not "neatly read a file
line by line" unless you open that file first. I found this out after
reading the first line of my text about two dozen times because I was
not opening the file. Here's the snippet that finally worked:
set txt_file to choose file with prompt "Choose a text file:"
try
set fref to (open for access txt_file)
set snippet to read fref for 25--I know that this will be long
enough to get a return
if snippet contains (ASCII character 10) then
set eol_delim to ASCII character 10
else
set eol_delim to ASCII character 13
end if
close access fref--have to close so I can read from the top
set fref to (open for access txt_file)--have to open it again so I
can loop through it
repeat 10 times--all the text files are the same so I know before
hand how many times to repeat
--the following line was the coolest thing about using this loop
--you get a nice list of text items without messing with TIDs
set field_data to text items of (read fref using
delimiter ": " before eol_delim as text)
set field_name to first item of field_data
set field_data to last item of field_data
(*I have a database open with a record waiting to put the data in
tell application "FileMaker Pro"
set data of cell field_name of last record to field_data
end tell
*)
end repeat
close access fref
on error errmsg number errnum
display dialog errmsg & errnum
close access fref
end try
On Monday, January 28, 2002, at 09:08 PM, applescript-users-
email@hidden wrote:
set stuff to read alias "Cortex:Users:tim:Desktop:pepper:anne sql"
close access f