cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Accessing the System clipboard in Arbortext Editor

mramshaw
1-Newbie

Accessing the System clipboard in Arbortext Editor

Does anyone know how to do this? The documentation says the default paste buffer is named 'default' but it only seems to be used when you copy/paste something within Arbortext, not another program (i.e. Word) on the system. I need to do symbol substitution when users paste something from Word and I got a paste callback function to work OK but there doesn't seem to be any way to access/modify what's being pasted. Any help would be appreciated.
5 REPLIES 5

If you write some Java code then you can access the clipboard in Epic using getSystemClipboard().getContents(), but if you don't want to go that route, then here is a simple ACL function that I use to get the contents of the clipboard as a string by pasting into a temporary document and storing the resutls. It will work with content that has been copied in an external application:

function getClipboardContents() {
# This function returns the contents of the clipboard as a string.
local $doc = doc_open('',0x100);
local savedoc = current_doc($doc);
local savecaret = oid_caret()
local savepos = oid_caret_pos()
paste;
clear_mark
goto_oid( oid_null() )
mark -noinvert -noselection begin
goto_oid( oid_null(), -1 )
mark end
local s = main::selection
doc_close($doc);
goto_oid( savecaret, savepos )
current_doc(savedoc)
return s
}

Cheers,

Dugald

Look up the function buffer_clipboard_contents in the online help. An
even easier way to do this.



John Dreystadt
Software Development Director
Arbortext - PTC
734-352-2835
-

In Reply to John Dreystadt:

Look up the function buffer_clipboard_contents in the online help. An
even easier way to do this.

Thanks a lot Dugald! I had to move up the lines with the savecaret and savepos declarations as shown below or else the paste kept happening at the beginning of the document instead of where the cursor was but aside from that, your function works great! Thanks again!

In Reply to Dugald Topshee:


function getClipboardContents() {
# This function returns the contents of the clipboard as a string.

local savecaret = oid_caret()
local savepos = oid_caret_pos()

local $doc = doc_open('',0x100);
local savedoc = current_doc($doc);
paste;
clear_mark
goto_oid( oid_null() )
mark -noinvert -noselection begin
goto_oid( oid_null(), -1 )
mark end
local s = main::selection
doc_close($doc);
goto_oid( savecaret, savepos )
current_doc(savedoc)
return s
}

Cheers,

Dugald

Yes, 5.3 and above.



John Dreystadt
Software Development Director
Arbortext - PTC
734-352-2835
-
Top Tags