• 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
deciphering TextCommand match info record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

deciphering TextCommand match info record


  • Subject: deciphering TextCommand match info record
  • From: Jim Brandt <email@hidden>
  • Date: Tue, 17 Apr 2012 08:38:51 -0500

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

  • Follow-Ups:
    • Re: deciphering TextCommand match info record
      • From: Axel Luttgens <email@hidden>
    • Re: deciphering TextCommand match info record
      • From: Thomas Fischer <email@hidden>
  • Prev by Date: Re: Run Handler-Name from Text?
  • Next by Date: Re: deciphering TextCommand match info record
  • Previous by thread: Re: Run Handler-Name from Text?
  • Next by thread: Re: deciphering TextCommand match info record
  • Index(es):
    • Date
    • Thread