title: Return Multiple Variables Dynamically from SETLOCAL
body: <p>I'm trying to figure how to return multiple variables, in a rather dynamic fashion where I just maintain a list of variable names and then do the <code>ENDLOCAL</code> "export" with a loop, but it seems the <code>!%%V!</code> expansion in the inner FOR loop isn't expanding soon enough or so.</p>
  
  <p>Is there something I'm missing or is there another way to accomplish this?</p>
  
  <p>Example code:</p>
  
  <pre><code>SETLOCAL EnableExtensions EnableDelayedExpansion
  [...]
  SET "RETURN=FOO BAR"
  [...]
  SET "RETURN=%RETURN% BAZ"
  [...]
  
  :END
  
  :: "Export" %FOO%, %BAR%, and %BAZ% to calling context.
  ENDLOCAL &amp; (
     FOR %%N IN (%RETURN%) DO (
        FOR /f %%V in ("%%N") DO SET %%N=!%%V!
     )
  )
  
     EXIT /B
  </code></pre>
  
  <p>Thank you for any help.</p>