• 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: find a string in a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find a string in a file


  • Subject: Re: find a string in a file
  • From: Emmanuel <email@hidden>
  • Date: Sat, 24 May 2003 02:10:30 +0200

At 12:45 PM -0700 23/05/03, Paul Berkowitz wrote:
>This will error if you text is larger than 32K bytes, because AppleScript
>can't do string comparisons ('contains') on strings larger than 32K. You'll
>have to do something like this for that case:
>
> set eFile to alias "EEHD:efile9.txt"
> set fileText to read eFile
>
> set start to 1
> set done to false
> repeat until done
> try
> set aChunk to text start thru (start + 30000) of fileText
> on error -- last chunk
> set aChunk to text start thru -1 of fileText
> set done to true -- won't repeat again
> end try
> if aChunk contains "%%" then
> display dialog "Found"
> return -- finish script now
> else
> set start to start + 30000
> end if
> end repeat
> display dialog "Not there" -- doesn't appear if found
>end try
>
>

or:

-------------------------- untested
set eFile to alias "EEHD:efile9.txt"
set fileText to read eFile

if offset of "%%" in fileText is 0 then
display dialog "Not there."
else
display dialog "Found"
end if
---------------------------------

Emmanuel
_______________________________________________
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: find a string in a file
      • From: Gary Lists <email@hidden>
References: 
 >Re: find a string in a file (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Detecting Default PDF reader/writer
  • Next by Date: Re: Finder error duplicating AppleWorks file
  • Previous by thread: Re: find a string in a file
  • Next by thread: Re: find a string in a file
  • Index(es):
    • Date
    • Thread