• 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
Property of a record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Property of a record


  • Subject: Property of a record
  • From: Jim Brandt <email@hidden>
  • Date: Tue, 17 May 2011 09:47:20 -0500

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

 _______________________________________________
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: Property of a record
      • From: Luther Fuller <email@hidden>
  • Prev by Date: Re[4]: tell app, name in string var
  • Next by Date: Next repeat?
  • Previous by thread: Re: tell app, name in string var
  • Next by thread: Re: Property of a record
  • Index(es):
    • Date
    • Thread