segunda-feira, 8 de julho de 2013

[BUG] Can't double For using same index variable

Did you get the post title? If not, don't worry, I'm aware of how horrible is sounds.

Truth is, in this case an image speaks better than a thousand words. If you look at the code below, you will understand my point.

If you run this code, you will get this nice error message:

Yep, QTP will complain at you with a sintax error, when you made no mistake.

"Invalid loop control variable"??? This is actually a mere limitation from VB Script language and I know that using the same variable twice on nested FORs is not the best option in programming space, but if your code is wrong it's up to the you (developer) to fix it, not your coding to block you with a sintax error.

WORKAROUND: Don't use the same variable in nested FORs twice or more. Instead, assign the index (variable i) to another variable and loop through it.

Nenhum comentário:

Postar um comentário