Reply to topic  [ 5 posts ] 
Rows of a table containing a search word 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
To get (the text of) the rows of a table that contain a search word: Is it necessary to transform the table into text, or can one obtain the rows directly?


2010-06-06 06:25:49
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
You do not need to convert the table to text; the macro language lets you work with table cell text directly. Assuming the selection currently rests in a table, here's a macro that tells you a little bit about the selected table:
Code:
# Get the first table selection
$selection = TableSelection.active
If ! $selection
   Prompt 'This macro only works if some part of a table is already selected.'
   Exit
End
$selectedRow = $selection.rowRange.location # first selected row
$selectedCol = $selection.columnRange.location

# get the table that is selected, and inspect some cells
$table = $selection.table
$firstCellText = $table.textAtRowAndColumn(0,0)
$firstSelectedCellText = $table.textAtRowAndColumn($selectedRow,$selectedCol)
Prompt "The text of the first selected cell: $firstSelectedCellText", "The text in the first cell of the table is $firstCellText"


2010-06-06 13:33:36
Profile WWW

Joined: 2007-04-12 14:59:36
Posts: 229
But how about text formatting? I can see from your example how to retrieve unattributed text from individual cells. But what I need is complete rows that have a sear word in one of the cells, with formatting. Would this be easier by first transforming the table into text?


2010-06-07 07:30:42
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
js wrote:
But how about text formatting? I can see from your example how to retrieve unattributed text from individual cells.
Those variables are attributed text. It is Prompt command that shows them as plain text. Try to output them to a new file, for example.

Quote:
But what I need is complete rows that have a sear word in one of the cells, with formatting.
It is your way of describing the problem that confused Martin, I think. If you had asked simply “How to get (the text of) the rows of a table that contain a search word?”, then you should have got something like this.
Code:
Menu ':Table:Select:Rows'
Menu ':Table:Copy Table Text'
which will put the text in the clipboard.


2010-06-07 09:00:56
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
Thank you Kino. Next time I will try to make myself better understood.


2010-06-07 10:29:04
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software