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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Modifying a selected range of text

ptc-953343
1-Visitor

Modifying a selected range of text

I'm trying to write an ACL script in 5.2 that will take a user selected
range of elements. In this case a series of step1 elements, take that
selection, delete and turn it into a seqlist with items. I can run the
following sample code at the command line and I get what I'm expecting:

copy_mark buf1;
delete_mark buf1;

response(oid_name(oid_first(buffer_doc(buf1))));
response(oid_content(oid_first(buffer_doc(buf1))));

paste buf1;

BUT when I put this in a file, create a funtion and assign it to the F12
key, the response messages show no content, the delete doesn't work but
the paste does. Any ideas on what is going on?


function step1_to_seqlist() {
copy_mark buf1;
delete_mark buf1;


response(oid_name(oid_first(buffer_doc(buf1))));
response(oid_content(oid_first(buffer_doc(buf1))));

paste buf1;

}

response("loaded");
map f12 step1_to_seqlist();


2 REPLIES 2

Hi Dan--

When using commands in a function, you need to be careful to put quotes
around literals like names. On the command line you can get away with
this:

copy_mark buf1

and Arbortext will figure out that you mean "buf1" to be the name of a
buffer. But in a function defined in an ACL file, you need to put quotes
around the buffer name so Arbortext knows you mean a literal name and
not a variable reference. So it should look something like this:

copy_mark "buf1"

This applies to all the references to the buffer in the function.

Also, w.r.t. the delete not working, you might need to add the -noclm
flag to the copy_mark command to prevent it from clearing the selection
after the copy. (Caveat: I'm using 5.3, so it's possible that 5.2 is
different, but I would be surprised.)

copy_mark -noclm "buf1"

So, in total, here's what works for me:

function testpaste() {
local buf1;
copy_mark -noclm "buf1";
delete_mark "buf1";
response(oid_name(oid_first(buffer_doc("buf1"))));
response(oid_content(oid_first(buffer_doc("buf1"))));
paste "buf1";
}

HTH

--Clay

I guess this quoting and non-quoting reflects the way the
documentation/help is setup. got to be careful about which help on a
function that you read.

The quotes fixed the problem as well as the -noclm. I read the -noclm as
not "deleting" when it said not clearing.

..dan


> Hi Dan--
>
> When using commands in a function, you need to be careful to put quotes
> around literals like names. On the command line you can get away with
> this:
>
> copy_mark buf1
>
> and Arbortext will figure out that you mean "buf1" to be the name of a
> buffer. But in a function defined in an ACL file, you need to put quotes
> around the buffer name so Arbortext knows you mean a literal name and
> not a variable reference. So it should look something like this:
>
> copy_mark "buf1"
>
> This applies to all the references to the buffer in the function.
>
> Also, w.r.t. the delete not working, you might need to add the -noclm
> flag to the copy_mark command to prevent it from clearing the selection
> after the copy. (Caveat: I'm using 5.3, so it's possible that 5.2 is
> different, but I would be surprised.)
>
> copy_mark -noclm "buf1"
>
> So, in total, here's what works for me:
>
> function testpaste() {
> local buf1;
> copy_mark -noclm "buf1";
> delete_mark "buf1";
> response(oid_name(oid_first(buffer_doc("buf1"))));
> response(oid_content(oid_first(buffer_doc("buf1"))));
> paste "buf1";
> }
>
> HTH
>
> --Clay
>
>
Announcements

Top Tags