Replied to fast. 

I changed `startLine *of* selection` to `endLine *of* selection` and now it 
moves to the next line after the selection.

Thanks,

Rainer


On Thursday, August 5, 2021 at 1:27:40 PM UTC+2 Rainer Krug wrote:

> Perfect. Thanks.
>
>
> On Thursday, August 5, 2021 at 12:52:26 PM UTC+2 listmei...@gmail.com 
> wrote:
>
>> On Aug 05, 2021, at 05:15, Rainer Krug <rai...@krugs.de> wrote:
>>
>>
>> I have the following AppleScript to execute het selected text in R and 
>> return the focus to BBEdit:
>>
>> ...
>>
>> Now I would like to set the cursor in BBEDit to the next line after the 
>> selected text ore line it is in.
>>
>> ------------------------------
>>
>> Hey Rainer,
>>
>> You can do something like this.
>>
>> --
>> Best Regards,
>> Chris
>>
>> ------------------------------
>>
>> *tell* *application* "BBEdit"
>>
>>     
>>     *set* startLineNum *to* startLine *of* selection
>>     *set* selectedText *to* selection's contents
>>
>>     
>>     *if* selectedText *is* "" *then*
>>         *try*
>>             *set* selectedText *to* contents *of* *line* startLineNum 
>> *of* *front* *document*
>>         *on* *error*
>>             *display dialog* "The active window must be an editor 
>> window, with a file opened. You want to run something in R? Well, tell me 
>> what!" with icon *note* buttons {"Got it!"} default button 1
>>             *error* number -128
>>         *end* *try*
>>     *end* *if*
>>
>>     
>> *end* *tell*
>>
>> tell application "R"
>>     cmd the_selection
>> end tell
>>
>> *tell* *application* "BBEdit"
>>     *activate*
>>     *tell* *front* *document*
>>         *try*
>>             *select* *insertion point* *before* *line* (startLineNum + 1)
>>         *on* *error*
>>             *select* *insertion point* *after* *line* startLineNum
>>         *end* *try*
>>     *end* *tell*
>> *end* *tell*
>>
>> ------------------------------
>>
>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/dd01b82c-b825-43eb-a2f6-b347dd110476n%40googlegroups.com.

Reply via email to