基于提取值的imacros javascript循环

时间:2014-12-01 06:57:19

标签: javascript imacros

这个循环调用macroWait,即使返回值extracttext不匹配 - 我做错了什么? 如果找到文本,我希望宏通过macrowait超时功能暂停,以允许该页面上的视频下载。 然后它应该进入下一次迭代并像以前一样查找Analysis文本。 如果找不到此文本,它将等待默认时间。

var macro;
macro =  "CODE:";
macro +=  "VERSION BUILD=9052613" + "\n"; 
macro +="SET !TIMEOUT_PAGE 25"+"\n";
macro +=  "URL GOTO=theURL=" + "{{theDate}}" + "&no=" + "{{theNumber}}" + "&lang=eng"+ "\n";
macro +="TAG POS=1 TYPE=A ATTR=TXT:<SP>Analysis EXTRACT=href"+"\n";

var macroWait;

macroWait ="CODE:";
macroWait +="WAIT SECONDS=600"; 
var iret;
var extracttext;    
var maxLoop=10;
var doesContain;
var theNumber =1;

for(var i=0;i<maxLoop;i++)
{
var curr = new Date(2014,0,1);
curr.setDate(curr.getDate()+i)
var theDate = curr.yyyymmdd();
iimSet("theDate", theDate);
iimSet("theNumber",n(theNumber)); 
iret = iimPlay(macro);
extracttext = iimGetExtract();
doesContain = extracttext.contains("passthrough");
//cannot find video then do not add timeout

if(doesContain == true)
{

iimPlay(macroWait)

}
else { next;}

}

1 个答案:

答案 0 :(得分:1)

如果'doesContain'得到布尔值为true或false,那么'(doesContain&gt; -1)'在任何情况下都为真。