Re: preflighting a file
Re: preflighting a file
- Subject: Re: preflighting a file
- From: Shane Stanley <email@hidden>
- Date: Tue, 19 Feb 2002 08:28:12 +1100
On 19/2/02 6:00 AM +1000, Emmanuel, email@hidden, wrote:
>
At 5:16 PM +0100 18/2/02, Debbie McNerney wrote:
>
>
> I am desperately trying to find/modify an applescript (drag and drop) that
>
> will search for and alert a user for this CalGray type. Can someone point me
>
> to the right direction. I am willing to put in some work to do this for our
>
> people here. Just need a little direction.
>
>
Maybe not the 'copy and paste' solution that you're after but just in case ...
>
>
You would open and read the file using the read/write commands included in
>
the Standard Additions (check the dictionary of Standard Additions with
>
Script Editor).
>
>
Then you would search for the desired string using the "offset" command:
>
>
------------------------
>
offset of subString in bigString
>
------------------------
>
>
returns the rank of subString in bigString, or 0 if not found.
>
>
Basically, thus:
>
>
------------------------ untested & unverified
>
set theFile to open for access alias thePath -- you provide thePath
>
set theText to read theFile
>
close access theFile
>
if offset of "CalGray" in theText is not 0 then
>
-- do whatever suitable
>
end
>
------------------------
Except that's going to give you the offset of the first "c" in the file, not
"CalGray", without help from third parties.
You will probably have to read in enough text to contain the relevant part,
and use text item delimiters:
set theFile to choose file
set fileref to open for access theFile
set someData to read fileref for 4024 -- however much you need
close access fileref
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"CalGray"}
set x to count of text items of someData
set AppleScript's text item delimiters to oldDelims
if x > 1 then
beep
display dialog "We have a right one here, Johnny..."
end if
--
Shane Stanley, 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.