I'm having a problem retrieving a part of a record. The record is the result of a search command from "TextCommands" using the find match info option.
The result is a list of records. Each record is described as:
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.
My problem is trying to extract the matched text from each record. (I think AS is confused because "text" is an AS property as well as a property within the record.)
Here's the snippet of code I've tried: ("x" contains the text of a table in HTML... I'm trying to isolate each row)
tell application "TextCommands" set y to search x for "<tr.*?</tr>" finding match info with regex set cnt to count of y repeat with row from 1 to cnt log item row of y -- debug show it in the log tell item row of y set tr to it's text range set tr_start to item 1 of tr set tr_end to item 2 of tr set RowText to it's text -- text of the row end tell set mess to (tr_start as text) & tab & tr_end as text set mess to mess & return & RowText display dialog mess -- debug end repeat end tell -- TextCommands
the log command displays the record as I expect it to be.
tr_start and tr_end display as expected but the variable RowText is always empty.
I read the paragraphs on pages 241-243 of Matt Neuburg's "Applescript The Definitive Guide" about properties of records, predefined properties and user properties. I thought the code snippet followed his suggestions about dealing with predefined properties of a record, but I doesn't work, at least in this case.
So, my question: what is the proper way to get a value of a record item when the named value used is also an AS property?
BTW, PowerPC running 10.4.11, Script Editor 2.1.2
TIA, Jim
|