Re: First Line of Selection?

2011-06-22 Thread Warren Michelsen
At 4:30 PM -0500 6/22/11, Christopher Stone sent 
email regarding Re: First Line of Selection?:

On Jun 22, 2011, at 10:52, Warren Michelsen wrote:
 Now then, I seem to be having a problem using 
AS to select the first line of a document's 
selection.  I've tried all kinds of things up 
to:


	set my_line to paragraph 1 of the selection 
of text document 1 of text window 1

__

Hey Warren,

It appears that you want to 'get' rather than 
'select' the first line of the selection.


Ummm..., once I've gotten it, where is it if I don't set something equal to it?



 How does one set a variable to the first line 
of the selected text of the front-most BBEdit 
document window?



It's easy once you figure out which object to 
reference which is not always straightforward in 
Applescript.  :)


 tell application "BBEdit"
   try
 tell text of front text window
   set my_line to line 1 of selection
 end tell


Seems strange telling something to the text. Very Object Oriented.



   on error errMsg number errNum
 set sep to "=="
 set e to sep & return & "Error: " & errMsg & return & sep & return ¬
   & "Error Number: " & errNum & return & sep
 beep
 display dialog e
   end try
 end tell

The new best practice with BBEdit is to 
reference the 'text of the front text window'.


Note that the code above will only provide a 
reference to the line object and not the 
contents thereof.


Noted.



 tell application "BBEdit"
   tell text of front text window
 set my_line to contents of line 1 of selection
   end tell
 end tell

Or as a one-liner:

 tell application "BBEdit" to set my_line to 
contents of line 1 of selection of text of front 
text window


That's what I changed to from:

tell application "BBEdit"
activate -- not taking any chances...
select text window 1
set the_text to the selection
set my_line to line 1 of the_text as text
end tell



HTH.


It does.



--
Best Regards,
Chris


Back atcha.

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.

Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>


Re: First Line of Selection?

2011-06-22 Thread Christopher Stone
On Jun 22, 2011, at 10:52, Warren Michelsen wrote:
> Now then, I seem to be having a problem using AS to select the first line of 
> a document's selection.  I've tried all kinds of things up to:
> 
>   set my_line to paragraph 1 of the selection of text document 1 of text 
> window 1
__

Hey Warren,

It appears that you want to 'get' rather than 'select' the first line of the 
selection.

> How does one set a variable to the first line of the selected text of the 
> front-most BBEdit document window?


It's easy once you figure out which object to reference which is not always 
straightforward in Applescript.  :)

 tell application "BBEdit"
   try
 tell text of front text window
   set my_line to line 1 of selection
 end tell
 
   on error errMsg number errNum
 set sep to "=="
 set e to sep & return & "Error: " & errMsg & return & sep & return ¬
   & "Error Number: " & errNum & return & sep
 beep
 display dialog e
   end try
 end tell

The new best practice with BBEdit is to reference the 'text of the front text 
window'.

Note that the code above will only provide a reference to the line object and 
not the contents thereof.

 tell application "BBEdit"
   tell text of front text window
 set my_line to contents of line 1 of selection
   end tell
 end tell

Or as a one-liner:

 tell application "BBEdit" to set my_line to contents of line 1 of selection of 
text of front text window

Scope out:

 tell application "BBEdit"
   tell text of front text window
     properties of selection
   end tell
 end tell

If you *had* wanted to *select* the line:

 tell application "BBEdit"
   tell text of front text window
 select first line of selection
   end tell
 end tell

HTH.

--
Best Regards,
Chris

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>


Re: First Line of Selection?

2011-06-22 Thread Christian Boyce
I think it is going to be easy.

tell application "BBEdit"
set the_text to the selection
set my_line to line 1 of the_text
end tell

Not "paragraph 1." Line 1. Took a long time to trial-and-error that over here.

c
On Jun 22, 2011, at 8:52 AM, Warren Michelsen wrote:

> This ought to be very easy. I have html documents containing tables. No 
> colspan or rowspan properties are used so each table row has the same number 
> of columns.
> 
> The documents are formatted such that each table row is one line in the 
> document; the line starts with " and ends with " so that a complete 
> row can be selected by selecting a complete line.
> 
> Now then, I seem to be having a problem using AS to select the first line of 
> a document's selection.  I've tried all kinds of things up to:
> 
>   set my_line to paragraph 1 of the selection of text document 1 of text 
> window 1
> 
> I keep getting the error: "An attempt was made to resolve an Apple Event 
> reference to a non-existent object."
> 
> How does one set a variable to the first line of the selected text of the 
> front-most BBEdit document window?
> 
> All I want to do is get the characters of that first line and count the 
> instances of " 
> I thought this was going to be easy... 
> 
> -- 
> You received this message because you are subscribed to the 
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbedit@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+unsubscr...@googlegroups.com
> For more options, visit this group at
> 
> If you have a feature request or would like to report a problem, 
> please email "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 


--
Christian Boyce
Christian Boyce and Associates
Mac, iPhone, and iPad Consultants
310-452-3720

Read the Boyce Blog: http://christianboyce.blogspot.com
Follow us on Twitter! http://twitter.com/christianboyce
Be a fan on Facebook! http://tinyurl.com/cboyce-and-associates-facebook

Now Playing on The Boyce Blog: Search Google Images by COLOR

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at

If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 


First Line of Selection?

2011-06-22 Thread Warren Michelsen
This ought to be very easy. I have html documents containing tables. No colspan 
or rowspan properties are used so each table row has the same number of columns.

The documents are formatted such that each table row is one line in the 
document; the line starts with " and ends with " so that a complete 
row can be selected by selecting a complete line.

Now then, I seem to be having a problem using AS to select the first line of a 
document's selection.  I've tried all kinds of things up to:

set my_line to paragraph 1 of the selection of text document 1 of text 
window 1

I keep getting the error: "An attempt was made to resolve an Apple Event 
reference to a non-existent object."

How does one set a variable to the first line of the selected text of the 
front-most BBEdit document window?

All I want to do is get the characters of that first line and count the 
instances of "http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: