title: How to use an environment variable for length in a variable string substitution?
body: <p>I have the following code:</p>
  
  <pre><code>set name=James
  echo %name:~0,4%
  </code></pre>
  
  <p>And it displays the first 4 letters of the variable: <code>Jame</code>.<br>
  But I'd like to insert a variable for the number of letters displayed which I can change with <code>set</code>. Something like this:</p>
  
  <pre><code>set num=3
  set name=James
  echo %name:~0,%num%%
  </code></pre>
  
  <p>The result should be showing the first <code>num</code> characters of string value of variable <code>name</code>.</p>
  
  <p>Is there any method to get desired result?</p>