I'm having problems with this chunk of my QuickCode parser:
for (i = 0; i < blockList.length; i++) {
if (func1.test(blockList[i])) {
return true
}
else if (func2.test(blockList[i])) {
return true
}
else if (func3.test(blockList[i])) {
return true
}
else if (func4.test(blockList[i])) {
return true
}
else if (func5.test(blockList[i])) {
return true
}
else if (func6.test(blockList[i])) {
return true
}
else if (func7.test(blockList[i])) {
return true
}
else {
alert("The debugger returned an error on block: Line "+i+1)
return false
}
}What happens, is that even if the length of the array blockList is greater than 1, the
for (i = 0; i < blockList.length; i++)
loop only loops around once. So even if the length of blockList is 7, the script only loops once.
This is the major bug that I am trying to deal with. Please help!
Offline
I don't know lava script at all, but maybe put a forever loop in it?
Offline
bbbeb wrote:
hows about:
Code:
i > blocklist.Length
No, because the variable "i" starts out as 0, so if it only loops WHILE "i" is GREATER than the length of blockList, then it will still loop once, because no matter what the length of blockList, 0 can never be greater than it!
If you have any more suggestions, I'd love to here them! I'm completely confounded by this problem!!!!!
Offline
return true will exit the current function. So maybe one of your test() functions is returning true?
function foo() {
for (i=0; i<20; i++) {
document.body.innerHTML += ('i is now ' + i + '<br>');
if (i==10) {
return true;
}
}
}The above loop will only loop through 11 (0 to 10) iterations, even though it has "i<20" there.
Here's a running example I made:
http://jsfiddle.net/EnWRZ/
(click the "[•] Run" button)
Hope it helps!
Offline
Thank you all so much
! Now I've finally gotten around the main bug in my parser!
Offline