I'm having a problem deciphering a record returned from the scripting addition "TextCommands".
I'm using a search command to return a "match info record", defined in the documentation as:
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.
I think my problem is that "text", a property of the record, is also an AppleScript built-in property.
Here's a sample script of what I'm trying to do:
set People to "George Mary Jill John"
set Boys to "George|John|Bill|Jim"
set Girls to "Mary|Jill|Susan|Cathy|Kathy"
tell application "TextCommands"
set HasBoys to check People contains Boys
set HasGirls to check People contains Girls
if HasBoys then
set theBoys to search People for Boys finding match info with regex
else
set theBoys to ""
end if
if HasGirls then
set theGirls to search People for Girls finding match info with regex
else
set theGirls to ""
end if
if HasBoys then
repeat with thisPerson in theBoys
set EachPerson to thisPerson
set t1 to item 1 of text range of EachPerson
set t2 to item 2 of text range of EachPerson
set theName to text of EachPerson
display dialog (t1 as text) & "," & (t2 as text) & " ==> " & theName
end repeat
end if
if HasGirls then
repeat with thisPerson in theGirls
set EachPerson to thisPerson
set t1 to item 1 of text range of EachPerson
set t2 to item 2 of text range of EachPerson
set theName to text of EachPerson
display dialog (t1 as text) & "," & (t2 as text) & " ==> " & theName
end repeat
end if
end tell
If I run this script, I can extract and display the individual t1 and t2 values defining the
range of each text item found, but I get an empty string for "theName" in each case.
If I look at the event log, it displays "theBoys" as:
{{text range:{1, 6}, text:"George"}, {text range:{18, 21}, text:"John"}}
and "theGirls" as:
{{text range:{8, 11}, text:"Mary"}, {text range:{13, 16}, text:"Jill"}}
so the records are being returned correctly, it's just my extraction of the
text value that isn't working.
So, how do I get the "text" value from the record?
FWIW, I'm running this on Tiger (10.4.11) on a G4 dual 450 and AppleScript Editor 2.1.2.
TIA,
Jim Brandt
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