Re: find a string in a file
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.