Paste not recognized - NEWBIE

Hello,

I have the following script,

tell application “BBEdit”
activate
set some_text to “PA Chamber of Commerce 1”
set the clipboard to some_text
paste some_text
end tell

I keep getting an error message stating paste is not recognized.

What I ultimately want to do is have a string of text printed X number of times on a page. I thought by assigning the text string to a variable it would be no problem but it just will not work. I’ve been through the BBEdit dictionary and have searched this forum with no luck.

Any thoughts would be greatly appreciated.

Scottman

hi scott,

why do you want to paste, “some_text”? shouldn’t you just ‘paste’ and whatever’s in the clipboard will go? seems like you’ve already got the value in the clipboard:


tell application "BBEdit"
    activate
    set some_text to "PA Chamber of Commerce    1"
    set the clipboard to some_text
    paste
end tell

i don’t have BBEdit, but this works in TextWrangler (the free BBEdit).

Waltr,

You were right.

I was always trying to tie the paste to a reference. It worked like a charm.

Thanks alot.

Scottman

Hi guys. (The following examples should work in BBEdit, too.)

Since you’re simply inserting text, you might try an even more direct approach (and bypass the clipboard altogether):

set application "TextWrangler"'s selection to "PA Chamber of Commerce 1"

Or, for a more realistic paste simulation:

tell application "TextWrangler"
	set selection to "PA Chamber of Commerce 1"
	select insertion point after selection
end tell

So your ultimate aim of repeated text, Scottman, might be achieved with something like:

tell application "TextWrangler" to repeat 5 times
	set selection to "some text" & return
	select insertion point after selection
end repeat

However, since that involves making multiple external calls to the application, it’s not a particularly efficient way to do the job. Probably better to create the repeated text in AppleScript and then insert it:

set source_text to "some text" & return
set paste_text to ""
repeat 5 times
	set paste_text to paste_text & source_text
end repeat
tell application "TextWrangler"
	set selection to paste_text
	select insertion point after selection
end tell