Workaround for "split" command (hangs in post import hook)

From AdeptersWiki

Jump to: navigation, search

Answered by: Brent Hartwig
Last Updated: 2006-09-22


package uOid;

...

# Boolean to workaround Epic split command bug -- hangs during post import hook.
# ATI30960. As of 20041213, Arbortext suggested using "<?Pub Caret?>" vs.
# "<?Pub Caret1?>" within XML import templates. This worked for 1 file but not
# another. Leaving "<?Pub Caret?>" in templates but turning workaround on.
global WORKAROUND_ATI30960 = 1;

...

#
# This function's only reason for existence is to provide an alternative to
# Epic's split command -- WHICH HANGS EPIC WHEN EXECUTED WITHIN THE POST
# IMPORT HOOK! The preceding is true at least with Epic 4.4K (ATI30960). This
# function isolates the workaround. The function behaves similar to Epic's
# split command in the respect the caret must be in the correct spot in the
# current doc. Compare $main::status to know if a call to this function was
# successful.
#
# THIS WORKAROUND HAS A DRAWBACK: The oids of elements that end up being
# cut and pasted elsewhere are no longer valid. 
#
function split( workaroundATI30960 = uOid::WORKAROUND_ATI30960 )
{
  if ( workaroundATI30960 )
  {
    local name = oid_name( oid_caret() );
 
    # Cut residual element content into paste buffer
    clear_mark all;
    mark -noinvert begin;
    goto_oid( oid_caret(), -1 );
    mark end;
    delete_mark bufSplitCmd;
    if ( main::status != 0 ) { return };

    # Move past end tag
    forward_char( 1 );
    if ( main::status != 0 ) { return };

    # Create new element
    insert_tag $name;
    if ( main::status != 0 ) { return };

    # Paste content
    paste bufSplitCmd;
    if ( main::status != 0 ) { return };
 
    # Place caret at beginning of new tag
    goto_oid( oid_caret() );
  }
  else
  {
    split;
  }
}

(Editor's comment by Karl Johan Kleist: Note Brent's clever bookkeeping of workarounds, which makes it easy to find out if new Arbortext releases fixes known problems without monkeying around with the code.)

Related content

How to prevent the "Modify Attributes" dialog when splitting an element?

Personal tools