22 Replies Latest reply on Jun 28, 2011 1:22 AM by RoboAsh

    How to read the CBTManager object

    Ton Blokhuizen

      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:

       

       

      27-6-2011 11-58-07.png

       

      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.

      27-6-2011 12-02-13.png

       

      Hope you can help!

       

      Thanx

       

      Ton Blokhuizen

        • 1. Re: How to read the CBTManager object
          Praful_Jain Level 3

          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

          • 2. Re: How to read the CBTManager object
            Willam van Weelden Adobe Community Professional & MVP

            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

            1 person found this helpful
            • 3. Re: How to read the CBTManager object
              Ton Blokhuizen Level 1

              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[i] = 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.

              27-6-2011 12-47-06.png

               

              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"
              

               

              ?

              • 4. Re: How to read the CBTManager object
                Ton Blokhuizen Level 1

                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

                • 5. Re: How to read the CBTManager object
                  Willam van Weelden Adobe Community Professional & MVP

                  Hi,

                   

                  What do you mean by "read all the current projects properties"? Do you want to show RoboHelp's own dialogs? I don't believe that's possible.

                   

                  Greet,

                   

                  Willam

                  • 6. Re: How to read the CBTManager object
                    Ton Blokhuizen Level 1

                    No, I do not want to show the RoboHelp dialog.
                    I just want to read the projects properties.

                     

                    To set the properties you only have to open the properties form like so:

                     

                    1) Select "Webhelp (primary layout)" within the "Single Source Layouts" Pod window.

                    2) Right click on this node

                    3) Select Properties

                     

                    The following form will be shown:

                     

                    27-6-2011 14-22-01.png27-6-2011 14-22-11.png

                     

                    I "just" want to be alble to read all of these properties in my script, eg the Conditional Build Tags expression

                    • 7. Re: How to read the CBTManager object
                      RoboAsh Level 2

                      Hi Ton,

                           Yes it is possible to read almost all the properties of any project please see the Object model viewer for RoboHelp 9 (for that you need to launch ESTK and then click Help->Object Model Viewer and then select RoboHelp object model).

                       

                      I am attaching a screen shot which shows few properties

                      ProjectProperties.JPG

                       

                      so you do have an option for accessing almost all the properties of any open project in RoboHelp

                       

                      Hope this will help

                      Ashish

                      • 8. Re: How to read the CBTManager object
                        Ton Blokhuizen Level 1

                        I've lacked to mentioned that we're using RoboHelp 8.

                        Is the ESTK also available in RH 8? and if so, I've looked around, but can't find it.
                        Do I have to install it ?

                         

                         

                        • 9. Re: How to read the CBTManager object
                          RoboAsh Level 2

                          Definitly it comes with RH 8 too please check in the All programs list it is called "Adobe ExtendScript tool kit CS4" and if you cannot find it that means you might have not installed it while installed RH 8 so you will re run the installer and you will find the check box to install Extend script toolkit

                           

                           

                          Ashish

                          • 10. Re: How to read the CBTManager object
                            Ton Blokhuizen Level 1

                            Hmm... I'm feeling a bit stupid .....

                            This is the program I'n using all the time.

                            Your screen capure and the letters ESTK were making me confused...

                             

                            I found it, but unfortunately I cannot select  "Robohelp"... only "ScriptUI Calsses" and "Core Javascript Classes"

                             

                            27-6-2011 15-01-42.png

                            Do I have to make some kind of reference to Robohelp?

                            • 11. Re: How to read the CBTManager object
                              Willam van Weelden Adobe Community Professional & MVP

                              Check if you have the ESTK CS 4. The ROM is only available in ESTK CS 4. CS5 will not show it... You probably have some CS5 program installed along with RoboHelp 8.

                               

                              The Object Model contains the same information as the scripting guide that Praful pointed out. The scripting guide also contains all objects, methods, properties etc. that you can access.

                               

                              Greet,

                               

                              Willam

                              • 12. Re: How to read the CBTManager object
                                Ton Blokhuizen Level 1

                                That's bad news.

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

                                • 13. Re: How to read the CBTManager object
                                  RoboAsh Level 2

                                  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

                                  • 14. Re: How to read the CBTManager object
                                    Willam van Weelden Adobe Community Professional & MVP

                                    That's great Ashish! Thanks a bundle.

                                     

                                    Greet,

                                     

                                    Willam

                                    • 15. Re: How to read the CBTManager object
                                      Ton Blokhuizen Level 1

                                      Super!

                                       

                                      Thanx a lot......

                                      Now it's time to figure out my actual problem of reading the project's properties.

                                      • 17. Re: How to read the CBTManager object
                                        Ton Blokhuizen Level 1

                                        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 :

                                        28-6-2011 9-18-54.png

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

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

                                        28-6-2011 9-33-18.png

                                        Strange because the intellisense is showing this:

                                        28-6-2011 9-40-26.png

                                         

                                        Anyway,

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

                                        28-6-2011 9-43-50.png

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

                                        28-6-2011 9-47-53.png

                                         

                                        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.

                                         

                                         


                                        • 18. Re: How to read the CBTManager object
                                          Willam van Weelden Adobe Community Professional & MVP

                                          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

                                          • 19. Re: How to read the CBTManager object
                                            Ton Blokhuizen Level 1

                                            That's clear.

                                             

                                            But how do i read the CBT expression filled out by the user?

                                            28-6-2011 9-43-50.png

                                             

                                            I need to do some filehandling depending on this expression.

                                            In my case I need to generate a specific XSL file depending on the CBT.

                                             

                                            The array contains all available CBT inside the project, but I need the CBT expression.

                                             

                                            Greet,

                                             

                                            Ton.

                                            • 20. Re: How to read the CBTManager object
                                              Willam van Weelden Adobe Community Professional & MVP

                                              Hi,

                                               

                                              According to the scripting guide, you can get the CBT of the SSL using the CBT method:

                                               

                                              1. First, determine the ssl to use and load that into a variable, for instance: ssl.

                                              2. Then read the CBT from the ssl:

                                               

                                              var myCBT = ssl.CBT;

                                               

                                              You should then have the CBT string.

                                               

                                              Greet,

                                               

                                              Willam

                                              1 person found this helpful
                                              • 21. Re: How to read the CBTManager object
                                                RoboAsh Level 2

                                                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

                                                • 22. Re: How to read the CBTManager object
                                                  Ton Blokhuizen Level 1

                                                  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!