retrieving the values of record
retrieving the values of record
- Subject: retrieving the values of record
- From: Jim Brandt <email@hidden>
- Date: Sat, 16 Apr 2011 19:56:04 -0500
I have a question about retrieving the values of a record.
I'm pulling some text out of an HTML file and trying to manipulate it using "TextCommands".
The text is in the title and contains an author's name and an article title, separated by a ":" i.e. <title>author name: Title of Article</title>
Looking at the documentation of "TextCommands", when you do a search command and ask for "finding match info" it returns a record containing:
Record Classes match info record -- A record describing the matched text. Returned by the search command when the 'finding match info' option is used. Properties: • text (r/o) Unicode text -- The matched text. • text range (r/o) list of integer -- The beginning and end indexes of the match.
So I put together a test script to try out a handler that would return a list with item 1 as the author name and item 2 as the title. I'm stuck where I get the record back from the search command in the handler.
set TitleText to "<title>Author: Title of article</title>" set A_T to my GetAuthorTitle(TitleText) set author to item 1 of A_T set title to item 2 of A_T display dialog author & return & title -- debug
on GetAuthorTitle(TitleText) set x to TitleText tell application "TextCommands" set author to "" set title to "" set x to search x for "<title>" replacing with "" set x to search x for "</title>" replacing with "" set y to search x for ":" finding match info set coords to text range of y -- this should be a list -- author and title to be filled in here return {author, title} end tell end GetAuthorTitle
When I run this with event logging on, I get this as a record: {{text range:{7, 7}, text:":"}} and this as an error "Can't get |text range| of {{text range:{7, 7}, text:\":\"}}."
So, my question is, how do I return the text range list pair into a variable?
TIA,
Jim |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden