1 Reply Latest reply on Jul 13, 2009 2:04 AM by sungnoone

    Passing parameters from plugin to script

    apruneda

      I need to pass some parameters from a plugin to a script. I have tried this method:


          PMString engineName("myengine");
          PMString scriptString("C:/Program Files/Adobe/Adobe InDesign CS4 Debug/Scripts/IterateFolder.jsx");
          IDFile scriptFile;
          scriptFile.SetString(scriptString);

          PMString value("c:/windows");
          ScriptData param1;
          param1.SetPMString(valor);

       

          ScriptIDValuePair argument1(0, param1);
             
          ScriptRecordData arguments;
          arguments.push_back(argument1);
          ScriptData result;
          PMString errorString;
          ScriptData scriptFileData(scriptFile);
          int32 errorCode=Utils<IExtendScriptUtils>()->RunScriptInEngine( engineName, scriptFileData, arguments, result, errorString);

       

       

      The problem is that I don´t really kwno how can I get the parameters in my script. I suppose it must be something like app.scriptArgs.getValue(), but i don´t really know. Could anybody help me?

       

      Thanks,

       

      Alvaro

        • 1. Re: Passing parameters from plugin to script
          sungnoone

          You may see scriptArgs object of application

          app.scriptArgs

          getValue()

           

          Lookign for more detail in object module viewer .

           

          This is a sample on my hand now!

           

          ( Code start )

           

          #target indesignserver_myid2

          //  active all master page items

          app.scriptArgs.set( "inputFile" , "/E/indesign/m000/math_2up.indd" );

          app.consoleout(" ");
          app.consoleout(".................................Script Running...................................");
          // get parameters
          if( app.scriptArgs.isDefined( "inputFile" ) ){
          var inputFile = app.scriptArgs.getValue( "inputFile" );
          if( checkFileExists( inputFile ) ){
            var inDoc = app.open( new File ( inputFile ) );
            activeObjs();
            inDoc.save();
            inDoc.close();
            app.consoleout( inputFile + " Activation page items OK! " );
            }
          else{
            app.consoleout( "InDesign document does not exists.  " + inputFile );
            }
          }
          else{
          app.consoleout(" No requirement parameters. ");
          }


          app.consoleout(" ==============Script End==================");
          app.consoleout(" ");

           

          ( Code end )