Skip to main content
Known Participant
June 27, 2011
Answered

How to read the CBTManager object

  • June 27, 2011
  • 4 replies
  • 2457 views

I'm making a special extendscript for my Robohelp project.

And is is going well.

Only I can't seem to figure out how te read the CBTManager object.

I need the Conditional Build Tags in the current project to proceed, but I can't seem to get it to work.

I probably doing something wrong, and help is appreciated.

The documentation is saying this:

So i tried the following:

   var CBT = RoboHelp.project.CBTManager;

   var CBTItem = CBT.item[0].name;

But all I get is [undefined].

CBTItem.count is returning 3 which is correct. My project has 3 CBT's defined.

But I want to know the names !!

The Documentation is saying the CBT has these properties, but I can't read them.

Hope you can help!

Thanx

Ton Blokhuizen

    This topic has been closed for replies.
    Correct answer RoboAsh

    That's bad news.

    I've just updated the ESTK because the version shipped with RH8 was crashing all the time.


    Hey Ton,

           not to worry that much, you can show it up by copying the XML shared @ https://acrobat.com/#d=v9IuLeOs1mfFewrY6gcS7A and place it under the path "C:\Program Files\Common Files\Adobe\Scripting Dictionaries CS4\robohelp" and it will start showing up in the ESTK object model viewer if it is ESTK CS4 and if it is ESTK 5 then just change the name of the folder "Scripting Dictionaries CS4" to "Scripting Dictionaries CS5".

    and in case you are using a 64 bit OS then place it under "Program Files x86" in place of "Program Files"

    Hope it will help

    Ashish

    4 replies

    Known Participant
    June 28, 2011

    Slowly I'm coming to my solution, but until then, I'm still struggling....

    I've found some object(classes) in which CBT are stored :

    The CBT (top in list) seems the one to be!

    But when i run my code, the result is "CBT is undefined"

    Strange because the intellisense is showing this:

    Anyway,

    I can't seem to figure out which object to use to extract the Conditional Build Tag expression:

    I've also look inside the set of HTMLHelp.... objects, but could not find any CBT objects or strings.

    I want to thank you all for helping me so far, we are going in the right direction.

    I did not come so far without all of your help!

    and hope you can help me come to a solution.


    Willam van Weelden
    Inspiring
    June 28, 2011

    Hi,

    The CBT is a sub class of the CBTManager. You cannot directly use this object. Instead you need to load a specific CBT using the CBTManager.

    In post 4 you load all CBT's into a new array. That's the way to do it. For instance:

    var C = new Array();

    function start() {

         var CBTM = RoboHelp.project.CBTManager;

         for(var i = 1; i<= CBTM.count;i++) {

              C.push(CBTM.item(i));

         }

    }

    This willl load all the CBT into the variable C. Whenever you want to get details about the CBT in your project, you need to cycle through the array C.

    Greet,

    Willam

    Known Participant
    June 28, 2011

    Posting a sample which can do this

    var MySSL = '' ;
    var Layout= "WebHelp"
    var project=RoboHelp.getCurrentProject();
    var sslMgr=project.SSLManager;


    for(var index=1;index<=sslMgr.count;index++)
    {
      if (sslMgr.item(index).name == Layout)
      {
       var MySSL = sslMgr.item(index);
       break;
      }
    }

    alert(MySSL.CBT);

    This can be used to alert the expression of the SSL with name WebHelp, Hope this will help

    Regards

    Ashish


    I'm feeling really really stupid .....

    I already had the code (see some posts back) to generate the project:

    var sslmngr = RoboHelp.project.SSLManager; var outputssl = false;     for(var i = 1; i<=sslmngr.count; i++)      {           var ssl = sslmngr.item(i);           if(ssl.name == "WebHelp Pro")           {                outputssl = ssl;                break;           }      } outputssl.CBT = "NOT NEWTAG1"; outputssl.generate();

    And instead of check if the CBT was already filled, I was focussing on filling it myself.

    How stupid!

    Thank you all for your help!

    And my excuses for being so dumb!

    Known Participant
    June 28, 2011

    [see post below]

    Willam van Weelden
    Inspiring
    June 27, 2011

    Hi,

    The CBTManager starts counting at 1. A little counterintuitive, but a rule of thumb: When the object has a count method, start with 1. Regular arrays start with 0 as in normal JavaScript.

    var CBTM = RoboHelp.project.CBTManager;

    for(var i = 1; i<=CBTM.count; i++) {

         var CBT = CBTM.item(i);

         alert(CBT.name);

    }

    Greet,

    Willam

    Known Participant
    June 27, 2011

    Check!

    I was confused by the zero and the use of brackets []

    Now it is almost working.

    var CBTList = new Array();

    var CBT = RoboHelp.project.CBTManager;

    for(var i = 1; i<=CBT.count; i++) {      CBTList = CBT.item(i).name }

    This code is getting all of the available CBT inside the project and tha'ts ok.

    Now I have to create a dialog like the "Define Conditional Build Tag Expression" so the user can apply the proper tags.

    I've seen some examples of creating a Dialog, so I thing I will be able to create one.

    But, how do I pass this expression to the actual building process?

    var outputssl = RoboHelp.SSLLayoutType.WEBHELPPRO

    outputssl.generate();

    is it as simple as:

    var outputssl = RoboHelp.SSLLayoutType.WEBHELPPRO

    outputssl.CBT = "NOT NEWTAG1 AND NOT Online"

    ?

    Known Participant
    June 27, 2011

    Ok, This is the solution:

    var sslmngr = RoboHelp.project.SSLManager; var outputssl = false;     for(var i = 1; i<=sslmngr.count; i++)      {           var ssl = sslmngr.item(i);           if(ssl.name == 'WebHelp Pro')           {                outputssl = ssl;                break;           }      } outputssl.CBT = 'NOT NEWTAG1'; outputssl.generate();

    But, one last question:

    Is it possible to read all the current projects properties?

    In that case I would not have to create my own dialog, but just read the properties, including the CBT.

    thanx

    Praful_Jain
    Participating Frequently
    June 27, 2011

    The only problem is all the iterator in RoboHelp Scripting object model starts from 1 and not 0.

    This is very much similar to Office macro support. so you should call

    var CBTItem = CBT.item[1].name;

    And it should work fine for you.

    thanks

    Praful