Skip navigation
Pontus Hulin
Currently Being Moderated

RunScript in CS5 and CS4? How do I set up RunScriptParams

Nov 15, 2010 3:30 AM

Hello

In SC3, I was able to run javascripts in Indesign using the following code:

 

     // add my arguments

     Utils<IScriptArgs>()->Save();    // create new script-args context on the stack
     for(int32 i=0; i < paramN.size(); i ++) {
          Utils<IScriptArgs>()->Set(paramN[i], paramV[i]);
           
     }
    
     // Get a handle on the ExtendScript Manager
     InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMg rBoss));
     if (!scriptManager)
          break;
           
     InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
     if (! scriptRunner)
          break;
           
     scriptRunner->RunScript(scriptStr2);

 

In CS5, this fails:

     InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
      if (! scriptRunner)
           break;

 

I have solved the problem by writing the script to a file and using:

 

InterfacePtr<IScriptRunner> scriptRunner( Utils<IScriptUtils>()->QueryScriptRunner(IDFile(pathToFile));

 

It works, but I do not want to have to write the script down to file before executing it.
Is there a way around this?

 

Best regards

     / Pontus

 
Replies
  • Currently Being Moderated
    Nov 15, 2010 5:04 AM   in reply to Pontus Hulin

    Hi,

    I'm not sure but perhaps if you try this :

     

    InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMg rBoss));
    if (!scriptManager)
              break;

     

    InterfacePtr<IScriptEngine> scriptEngine(scriptManager->QueryDefaultEngine ());
    if (!scriptEngine)
              break;

     

    // IScriptRunner aggregate same boss than IScriptEngine

    InterfacePtr<IScriptRunner> scriptRunner(scriptEngine, UseDefaultIID());

    if (! scriptRunner)
              break;

     

    RunScriptParams params(scriptRunner);

    scriptRunner->RunScript(scriptStr2,params);

     

    Ludo.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 17, 2012 11:38 PM   in reply to Pontus Hulin

    Hi,

     

    I got exception when tried above code as -

     

    error C2065: 'kJavaScriptMgrBoss' : undeclared identifier

     

     

    please tell me the solution.

     

    Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 10:33 PM   in reply to JohnAnt185

    Hi,

     

     

    JohnAnt185 wrote:

     

     

    I got exception when tried above code as -

     

    error C2065: 'kJavaScriptMgrBoss' : undeclared identifier

     

     

    try with including the header file -

     

    #include "JavaScriptID.h"

     

    Thanks.

    Deepak.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points