title: How to parametrize JMeter Loop Controller with Groovy function?
body: <p>I am pretty new to Jmeter but can handle &quot;simple&quot; test plans. I really do need help with the issue I am facing. Currently I run into a problem regarding how to parametrize the Loop Controller loop count Groovy function.</p>
  <p>I did found a lot of examples but they are all with static loop count like: ${__groovy(new File('test.csv').readLines().size(),)}.
  I really would like to parametrize the part 'test.csv'. Therefor I replaced that with ${csvFile}, like:</p>
  <pre><code>
  ${__groovy(new File(${csvFile}).readLines().size(),)}.
  </code></pre>
  <p>In the 'User Defined Variables' section of the 'Test Plan' I created the variable 'csvFile'.
  <a href="https://i.stack.imgur.com/PbtbN.png" rel="nofollow noreferrer">Test plan image in here</a></p>
  <p>When I execute the script I retrieve an error in the log like:</p>
  <pre><code>2022-01-25 11:35:14,870 WARN o.a.j.f.Groovy: Error running groovy script
  javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  Script16.groovy: 1: Unexpected input: '\' @ line 1, column 12.
     new File(D:\devenv\projecten\JM_InterestDeterminationService\inputmessages.csv).readLines().size()
                ^
  
  1 error
  
  </code></pre>
  <p>Is the error pointing to the backslash? Is that because of the Windows OS?</p>
  <p>Must I replace the '\' with a '/'? How and where can I do that?
  I started fiddling around with .replaceAll(&quot;\\&quot;, &quot;/&quot;) and .replaceAll(&quot;\\\\&quot;, &quot;/&quot;), but I don't know where to put it and what the correct syntax is.</p>
  <p>Could any of you please help me?</p>