Re: Read a text file ...
Re: Read a text file ...
- Subject: Re: Read a text file ...
- From: John Delacour <email@hidden>
- Date: Sat, 19 Apr 2003 20:54:32 +0100
- Mac-eudora-version: 6.0a16
At 11:12 am -0700 19/4/03, Charles Heizer wrote:
Hi John,
This looks great, thanks a bunch.
I do have a question about the results, how do I map the items from
the text file to my variables?
example...
set theHost to "myfirsthost.example.com"
set theUser to "user"
set thePass to "password"
writeFile() -- make the sample file see (**) below
set le to ASCII character 10
set fU to "/tmp/host.txt" -- UNIX pathname of file
set f to POSIX file fU -- file specification
if (read f for 1000) contains return then set le to return
set lLines to (read f using delimiter le)
set sSeparator to ";"
set text item delimiters to ";"
repeat with lLine in lLines
set ls to text items of lLine
set {hHost, uUser, pPass} to {"err", "err", "err"}
if (count ls) is 3 then set {hHost, uUser, pPass} to ls
log uUser & "....." & pPass
end repeat
set text item delimiters to ""
(**)
on writeFile()
set fU to "/tmp/host.txt"
set f to POSIX file fU
set s to "myfirsthost.example.com;user;password
host2.example.com;user2;password2"
open for access f with write permission
set eof f to 0
write s to f
close access f
end writeFile
_______________________________________________
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.