• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Read a text file ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read a text file ...


  • Subject: Re: Read a text file ...
  • From: John Delacour <email@hidden>
  • Date: Sat, 19 Apr 2003 20:53:31 +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.

References: 
 >Re: Read a text file ... (From: Charles Heizer <email@hidden>)

  • Prev by Date: Re: applescript-users digest, Vol 3 #1583 - 12 msgs
  • Next by Date: Upcoming changes to Palm Desktop scripting (1 of 2)
  • Previous by thread: Re: Read a text file ...
  • Next by thread: Re: Read a text file ...
  • Index(es):
    • Date
    • Thread