• 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: applescript-users digest, Vol 2 #1455 - 5 msgs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: applescript-users digest, Vol 2 #1455 - 5 msgs


  • Subject: RE: applescript-users digest, Vol 2 #1455 - 5 msgs
  • From: Joe Kelly <email@hidden>
  • Date: Sat, 5 Jan 2002 16:30:51 -0800

First off, open your text file using "open for access":

set ref to open for access ("HD:blah:blah:theFile" as alias)
set myText to read ref as text
close access ref

You now have the text from the file in myText. You could be spiffy and
eloquent and use some of the Akua Sweets string commands, or you can be
gruff and slow and do it this way:

set resultText to ""

repeat
set x to (offset of "/*" in myText)
if (x is 0)
exit repeat
end if
set y to (offset of "*/" in myText)
set s to (items x through y of myText) as text
set myText to (items (y+1) through (count of myText) of myText) as
text
set resultText to resultText & s
end repeat

DoSomethingWithComments(resultText)

The case of embedded C comments will break this script, and is left as
problem for you to solve. Did somebody say recursion?

/* this is a comment
/* oh no, someone embedded
another comment! */
*/

> -----Original Message-----
> From: jason batt [mailto:email@hidden]
> Sent: Wednesday, February 06, 2002 3:11 AM
> To: email@hidden
> Subject: Re: applescript-users digest, Vol 2 #1455 - 5 msgs
>
>
> Hello People
> Heres my problem -
> How can I read only specific text from a text file, ie only the text
> between two markers eg "/*" and "*/" and then write this text into a
> newly created text file with the same name as the original at a
> differant location on my hardrive. (Bearing in mind that there are
> multiple sets of markers in each text file as its the
> comments from some
> code)
> Regards
> Jason
> --------------------------------------------------------------
> Microspot Ltd - Testing & Technical Support
> email@hidden
> --------------------------------------------------------------
> _______________________________________________
> 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.


  • Follow-Ups:
    • Re: applescript-users digest, Vol 2 #1455 - 5 msgs
      • From: Bill White <email@hidden>
  • Prev by Date: Re: Sending Info over the web to a Mac.
  • Next by Date: Re: applescript-users digest, Vol 2 #1455 - 5 msgs
  • Previous by thread: Re: Sending Info over the web to a Mac.
  • Next by thread: Re: applescript-users digest, Vol 2 #1455 - 5 msgs
  • Index(es):
    • Date
    • Thread