• 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: Reading input from a delimited source file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading input from a delimited source file


  • Subject: Re: Reading input from a delimited source file
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Thu, 09 Jan 2003 10:33:20 -0500

> Date: Wed, 8 Jan 2003 13:10:58 -0600
> Subject: Reading input from a delimited source file
> From: Joseph Weaks <email@hidden>

> What am I doing wrong? I have a text file that has paragraph delimited
> data. Basically, I want to read the content of the first paragraph, do
> stuff with it, then repeat with each paragraph. Here's what I've been
> trying:

> -- Begin code snippet
> Property sourceFile : "Source.txt"
>
> set theSource to (open for access file ((path to desktop as string) &
> sourceFile as string)
>
> set AppleScript's text item delimiters to (ASCII character 13)
> set sourceList to text items of theSource

theSource is a file-reference number. You need to read the file, and
not simply open it for read-access.


> Right now, each paragraph is only one word, so there's not a problem
> loading the whole file into memory.

This this situation, it is not nessesary to use the "open for access"
command at all:

set str to read ( some-file )

both opens, reads, and closes a file if it has not previously been opened.


{ Arthur Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m

"Safe the Nature" - political graffiti in Prague
}
_______________________________________________
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.

  • Prev by Date: Re: Null
  • Next by Date: Scripts as Service?
  • Previous by thread: password syntax for remote access
  • Next by thread: Re: Reading input from a delimited source file
  • Index(es):
    • Date
    • Thread