• 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: Complete & Total Novice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Complete & Total Novice


  • Subject: Re: Complete & Total Novice
  • From: Gary Lists <email@hidden>
  • Date: Fri, 13 Jun 2003 01:27:07 -0400

On or about 6/12/03 11:41 PM, Jon Pugh wrote:

> At 7:47 PM -0700 6/12/03, Jim Bennett wrote:
>> So my question is this: "Is this something that Applescript could handle or
>> should I just do a batch search using BBEdit?"
>
> I start with a batch search and then massage it with AppleScript if I need to
> do it a bunch of times. If just once, I'll use Replace All to turn it into
> something you can import into some other app or turn into a report or
> something.
>
> Jon


Okay, perhaps this will be of some use.

I elected to dump only the 'attributes' property (which is a record
itself)[1] of the 'tag' property (which is a record itself) of the 'tag
result' record (enough hierarchy for you?) into the accumulating list
called 'metae'. I do, however, use some other properties[2] from the full
'tag result' record, to know whether we found anything[3] and where the last
offset was. Make sense? Sure it will...

So, the end result of this script is that you have a property/variable,
called 'metae', which contains a list of records, one per meta tag found in
the file(s) that you feed it.[4] The records contain the mark up attributes
from each meta tag (which may be different, i.e, the 'properties' are not
parallel.)

I just have the handler return true or false for success or error, but you
could just as easily return the big list from handler to 'set' something, or
'set' a global inside the handler instead of using a property.

Six of one...half dozen the other...I think. (?)


-- Metae Miner v0.1
-- tested with BB6.1, AS 1.8.3

property metae : {}


set pFile to choose file of type "TEXT" -- or write a real drop handler :)
mineMetae(pFile)


to mineMetae(thisFile)
local mOffset, done

set mOffset to 0
set stillgoing to true

try
tell application "BBEdit 6.1"
-- activate
open thisFile

repeat until not stillgoing
set thisMetaRec to (find tag "META" start_offset mOffset)
-- update looping controls
set stillgoing to found tag of thisMetaRec
if stillgoing then
set mOffset to (thisMetaRec's tag's end_offset)

-- mine meta data
set end of metae to thisMetaRec's tag's attributes
end if
end repeat

end tell
return true
on error
return false
end try
end mineMetae


HTH
--
Gary



[1] BBEdit returns a 'tag result' record, including a property called
'tag:', if there was, indeed, a successful find, and that property (tag:)
has a property called 'attributes:'. That property looks like this sample:

{..., attributes:{|http-equiv|:"Content-Type", content:"text/html;
charset=iso-8859-1"}}

You are getting the name/value pairs in the mark up attributes of the
<META...> tag.

[2] The full 'tag result' record, when a result is found, looks like this:

{class:tag result, found tag:true, tag:{class:tag info, name:"meta", is
close tag:false, is empty xml element:false, start_offset:203,
end_offset:274, attributes:{|http-equiv|:"Content-Type", content:"text/html;
charset=iso-8859-1"}}}

[3] And when there is no result found, then it has, of course, no tag
attribute at all, therefore looks like:

{class:tag result, found tag:false}


[4] A more 'full' result, from a <meta...> tag with a bit more data:

{|http-equiv|:"Content-Type", content:"text/html; charset=iso-8859-1"},
{|http-equiv|:"Script-Type", content:"text/javascript;CHARSET=iso-8859-1"},
{|name|:"Author", content:"NicheCrafters"}, {|name|:"Copyright",
content:"Copyright 2003 by NicheCrafters.com. All rights reserved."}

--
MacOS 9.1 / "9 is Fine"
OMM: osa:AS 183 / osa:JS 103 / FM 55 / BB601 / Smile 188
______________________________________________________________
Please reply directly to the list.
Incoming messages are auto-deleted. (It's anti-spam, that's all.)
_______________________________________________
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: Complete & Total Novice
      • From: Gary Lists <email@hidden>
References: 
 >Re: Complete & Total Novice (From: Jon Pugh <email@hidden>)

  • Prev by Date: Re: Resurgence in AppleScript interest
  • Next by Date: Re: Complete & Total Novice
  • Previous by thread: Re: Complete & Total Novice
  • Next by thread: Re: Complete & Total Novice
  • Index(es):
    • Date
    • Thread