下面是一個例子三重陣列彎針(帶靜態變量,以便可以看到它改變)
這是一個自定義的我已,注意語法用於存儲增量變量(如計數器等)
這個活套將循環所有的選項(在下面的例子中有6 * 5 * 4 = 120個選項)。它會將每個選項回顯一次,然後移至下一個選項。
example_array_looper
storeEval new Date().getTime(); timeStart
echo ${timeStart}
storeEval new Array("1","2","3","4"); toparray
storeEval new Array("A", "B", "C", "D", "E"); middlearray
storeEval new Array("i","ii","iii","iv","v","vi"); bottomarray
getEval topindex=0;
getEval middleindex=0;
getEval bottomindex=0;
getEval loopCounter=0;
while topindex < storedVars['toparray'].length
storeEval topindex temptop
while middleindex < storedVars['middlearray'].length
storeEval middleindex tempmiddle
while bottomindex < storedVars['bottomarray'].length
storeEval bottomindex tempbottom
echo javascript{storedVars['toparray'][storedVars['temptop']]+" -> "+storedVars['middlearray'][storedVars['tempmiddle']]+" -> "+storedVars['bottomarray'][storedVars['tempbottom']]}
getEval bottomindex++;
getEval loopCounter++;
endWhile
getEval bottomindex=0;
getEval middleindex++;
endWhile
getEval bottomindex=0;
getEval middleindex=0;
getEval topindex++;
endWhile
storeEval loopCounter loops
echo Total number of loops is: ${loops}
storeEval new Date().getTime(); timeEnd
echo ${timeEnd}
storeEval (${timeEnd}-${timeStart})/1000 scriptRunTime
echo Total Run Time for Script was: ${scriptRunTime}s
storeEval ${scriptRunTime}/${loops} averageTime
echo Average Loop Duration was: ${averageTime}s
我選擇刪除所有的html標記(所以差距應該很明顯)。 StoreEval命令最適合保存循環計數器,因爲您可以在一步而不是2步中將它們用作增量。