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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

arbortext 6 Macro help to automate creating an index entry into a table

bfriesen
18-Opal

arbortext 6 Macro help to automate creating an index entry into a table

Hi I need some help creatinga macro that will copy the contents of a cell and create an index tag with those contents. I have created one but it only works with 6 digit numbers and only can do one cell at a time. We have a mix of 4, 5 and 6 digit part numbers. What I would like to do is select the entire column, maybe 20 or entries and run this macro and have an index tag created for each one. I cannot seem to change the amount of characters that I can select or number of cells as I seems to mess everything up if I do it that way

Here is what I got

#Enter;

insert_tag("indexterm");

LineUp;

CharLeftExtend; repeat 5;

EditCopy;

LineDown; repeat 2;

EditPaste;

Thanks Bryon

ACCEPTED SOLUTION

Accepted Solutions

The code above always adds indexterm to the 1st column

Here is the slightly updated code which adds indexterm to the column where cursor is located (haven't validated it - writing from home and I'm sane enough not to have Arbortext installed on my home laptop

But it should work.

$table_rows=tbl_row_count()

$column_to_process=tbl_caret_col()

while(tbl_caret_row() <= $table_rows && tbl_caret_row() > 0) {

oid_select(oid_caret(0))

copy_mark mymark

insert_tag(indexterm)

paste mymark

# insert("-")

if (goto_cell(tbl_caret_row()+1, $column_to_process) != 1)

{

break

}

}

View solution in original post

4 REPLIES 4
pnagai
12-Amethyst
(To:bfriesen)

Hi Bryon,

I think you are going to find more reliable results using the oid_xxxx commands within ACL (Arbortext Command Language). Search help for oid_select for starters. It will require learning to think about your document as a node tree, not strings of characters (except at the far, leafy tips of that tree).

I would use the following approach the problem you've presented.

Get the OID (this is the name of the XML node, or Object IDentifier, every oid is unique within a document) for the table. Get the oid for the tgroup (I am assuming CALS table model). Get the oid for the tbody. Get the list of oids for the rows. Copy the contents of the first entry. (How you execute the previous step may be different depending on how the number is inserted in <entry>.) Move the cursor into the first entry. Insert <indexterm>. Insert the copied contents. Repeat for the rest of the rows. (Don't forget to handle exceptions like no data in entry, merged cells, etc.)

Here is an example of one of those steps:

audiences = oid_find_children($theater_oid, audience_arr, "audience");

This takes a known oid ($theater_oid) and collects all of the oids of its <audience> children and stores those oids in an array, audience_arr[]. $audiences is filled with the number or count of <audience> children found. Now I can process each of those audience elements like this:

for (i = 1 ; i <= $audiences ; i++) {

name = get_name(audience_arr[$i];

response($name . ' is sitting in seat number ' . $i . '.')

} # for

Hope that helps.

You should consider joining the Adepters mailing list where lots and lots of Arbortext users, admins, and developers hang out 24/7/366 (it is a leap year, you know!). Information on joining that list (as well as pointers to lots of other Arbortext resources) can be found here:

http://blog.single-sourcing.com/top-arbortext-resources

Good luck!

Hi Bryon

See below a simple ACL script which seem to do what you need.

Also see the video demoeing it: http://communities.ptc.com/videos/2679

$table_rows=tbl_row_count()

while(tbl_caret_row() <= $table_rows && tbl_caret_row() > 0) {

oid_select(oid_caret(0))

copy_mark mymark

insert_tag(indexterm)

paste mymark

# insert("-")

if (goto_cell(tbl_caret_row()+1, 1) != 1)

{

break

}

}

The code above always adds indexterm to the 1st column

Here is the slightly updated code which adds indexterm to the column where cursor is located (haven't validated it - writing from home and I'm sane enough not to have Arbortext installed on my home laptop

But it should work.

$table_rows=tbl_row_count()

$column_to_process=tbl_caret_col()

while(tbl_caret_row() <= $table_rows && tbl_caret_row() > 0) {

oid_select(oid_caret(0))

copy_mark mymark

insert_tag(indexterm)

paste mymark

# insert("-")

if (goto_cell(tbl_caret_row()+1, $column_to_process) != 1)

{

break

}

}

Thank you Dmitry your knowledge of the product is great, again thanks for all your help.

Bryon

Announcements

Top Tags