Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Excuse me. I don't like this type of code. In my personal opinion, it is much clear to manage these values as an <em>array</em> this way:</p> <pre><code>rem Prepare the array of two-digits values for each 3-letters month names: for %%a in ("Jan=01" "Feb=02" "Mar=03" "Apr=04" "May=05" "Jun=06" "Jul=07" "Aug=08" "Sep=09" "Oct=10" "Nov=11" "Dec=12") do ( set month%%~a ) rem Previous code is equivalent to these 12 lines: rem set monthJan=01 rem set monthFeb=02 . . . . rem set monthDec=12 rem This way, the result is immediately accessible: SET v=May CALL SET v=%%month%v%%% rem Or in the clearer way using Delayed Expansion: SET v=!month%v%! </code></pre> <p><code>monthXXX</code> is an <em>array</em> of values for 12 different 3-letters month names.</p> <p><code>SET v=May</code> set the value of the <em>index</em> to an element array.</p> <p><code>SET v=!month%v%!</code> is first expanded to <code>SET v=!monthMay!</code> (normal expansion), and then to <code>SET v=05</code> (Delayed Expansion).</p> <p>I had explained the reasons I have to prefer this notation with every detail in these posts:</p> <p><a href="https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990">Arrays, linked lists and other data structures in cmd.exe (batch) script</a></p> <p><a href="https://stackoverflow.com/questions/10544646/dir-output-into-bat-array/10569981#10569981">DIR output into BAT array?</a></p> <p>I apologize if someone thinks this answer is off-topic...</p> <p>Antonio</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload