Hi James,
Have you tried using ArgsContext.i where i is the variable used in the for loop.
I have made some test in my LoadRunner 12 environments with the following line of code and I do not receive error messages.
evalXPath("//td[text()=\""+ArgsContext.i+"\"]");
In your case it should be
evalXPath("(//a[text()=\""+ArgsContext.q+"\"])[1]");
if in the for loop you are using q as an iteration variable.
Please make sure that you are using only English letters in the function as it can also cause issues.
Please see the following thread
Please try it and let us know the outcome.
Thank you in advance.
Kind regards,
Vesela