如何将imacros中的变量传递给javascript?

时间:2016-02-12 15:15:18

标签: javascript variables eval imacros

我需要将imacros的值乘以javascript值。 我可以将javascript值传递给imacros,但是imacros无法将它乘以它。 另外,我没有找到任何解决方案,如何从imacros中提取变量并将其传递给javascript。

var macro, iret;
var JsNumber = 5;

function macro1()

{
   iimSet("VAR1", JsNumber);
   macro = "CODE:";
   macro += "VERSION BUILD=8961227 RECORDER=FX\n";
   macro += "CMDLINE !DATASOURCE c:\\database.csv\n";
   macro += "SET !DATASOURCE_LINE 1\n";
   macro += "SET !VAR2 {{!COL1}}\n";
   macro += "SET !VAR3 EVAL(VAR1 * VAR2)\n";
   macro += "PROMPT {{!VAR3}} !VAR4\n";
   iret = iimPlay(macro)
}

{
   macro1();
}

2 个答案:

答案 0 :(得分:1)

解决方案是:iimGetExtract() 这可以将imacros脚本中的变量赋予javascript。

答案 1 :(得分:1)

var macro, iret;
var JsNumber = 5;


var theReturn=macro1(JsNumber);


function macro1(JsNumber)

{
   iimSet("VAR1", JsNumber);
   macro = "CODE:";
   macro += "VERSION BUILD=8961227 RECORDER=FX\n";
   macro += "CMDLINE !DATASOURCE c:\\database.csv\n";
   macro += "SET !DATASOURCE_LINE 1\n";
   macro += "SET !VAR2 {{!COL1}}\n";
   macro += "SET !VAR3 EVAL(VAR1 * VAR2)\n";
   macro += "SET !EXTRACT {{!VAR3}}\n";
   macro += "PROMPT {{!VAR3}} !VAR4\n";
   iret = iimPlay(macro)

   var ret=iimGetLastExtract();

return ret;

}

试试这个......