Assigning a new default TOC and then deleting the first TOC

In TCS2, this code that sets the second TOC as the default and then deletes the first TOC worked consistently.

if (RoboHelp.project.TOCManager.item(2).setAsDefault()) {

RoboHelp.project.TOCManager.item(1).delete();

}

In TCS4, the same code sometimes crashed the script, so I had to add this code close and then reopen the project, and then check whether the TOC that I’m trying to delete is the default, before deleting the old TOC. I suspect inserting a delay would achieve the same thing – if you try it and it works, let me know.

if (RoboHelp.project.TOCManager.item(2).setAsDefault()) {

var projectName = fsName(RoboHelp.project.path) + “\\” + RoboHelp.project.name + “.xpj”;
RoboHelp.closeProject();
RoboHelp.openProject(projectName);

if ( RoboHelp.project.TOCManager.item(1).name.indexOf(“Default”) == -1) {
RoboHelp.project.TOCManager.item(1).delete();
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s