penpen wrote: ↑21 Sep 2019 18:26
I'm not sure what you mean there... .
In case you want the order in a simpler format, where you have to change only one index per entry in your example, then you might encapsulate that in an array, too
That would make it simpler to change the order for the original hard-numbered array concept, true. Good example for that. The script I'm making is for rather novice users to edit if they need so my goal was more ease of changing order and adding new variables for user 'settings' (pre-set variables at the top of the script).
For example let's say the batch script comes with three 'settings' in the following order:
Code: Select all
set choice-ball=value
set choice-sun=value
set choice-land=value
I have the script obtain that list as it appears in that order and echo it for a choice prompt, with 'ball' and its value being first, 'sun' second, 'land' third. Then let's say a user wants to move the 'land' value to appear first for the prompt. Using this method all they'd have to do is cut and paste the 'land' line above the 'ball' line and it would now appear first (or if using a decent text editor shift the line upward using a hotkey). A simple change and the script would automatically account for it in the choice prompt.
Whereas if the initial variables had digits in the names it would require either re-numbering via a separate variable (eg: the
menuItem example in the post above) which is a bit more involved particularly if settings want to be added/removed, or hand editing/re-numbering the digit order (or even re-arranging all the label/content pairings).
So in that sense I'm fond of the more straightforward findstr approach even if it has the caveat of having issues with certain characters in paths (I'll be including a regular
set var for loop fall back approach in such cases). If it was just for my own use it wouldn't matter much the method, although honestly even I like just being able to simply re-arrange/add/remove the lines and have it reflected in the order