May 2, 200620 yr Attached is a demonstration of how to use SET to dynamically assign variables when their names are made from other variables' values.It makes use of the CALL command and of the righ number of %s.The demonstration is a simple menu application, displaying labels, asking for the user's choice and returning a custom data associated with the label.For any use it could have.Choice.cmd
May 3, 200620 yr Djé, nice idea, how about pick_one.cmd. It is based on a similar idea, but its syntax will not be obvious to understand.To use it, which is probably a good idea in the first instance, drop a reasonably high level folder onto it or run it from the command line with the folder path as a parameter.[note] It would of course only work in this case if you had txt files in your chosen folder structure[/note]
May 3, 200620 yr Attached is a demonstration of how to use SET to dynamically assign variables when their names are made from other variables' values.It makes use of the CALL command and of the righ number of %s.The demonstration is a simple menu application, displaying labels, asking for the user's choice and returning a custom data associated with the label.For any use it could have.That a nice little demo, keep up the good work.Yzöwl nice work, pick all the text file out and place them on a menu. Edited May 3, 200620 yr by gunsmokingman
May 3, 200620 yr Author Thanks dudes.Yzöwl, I'm too tired for tonight and really could not grab the entire mechanism yet. But I'm suspecting you acheived something great... I'll have to investigate tomorrow morning with a good coffee...
May 4, 200620 yr Author In Choice.cmd, in order to get rid of the quotes in the displayed strings we can use::SETVALUESSET %TYPE%%I%=%~1GOTO :EOF[only added a tilde (~) inside %1]No solution yet for the question marks...@Yzöwl: I feel better today and got it.Yesterday, I though you had somehow managed to make a multi-lines variable , because of:ECHO/.%PICK% |FINDSTR/C:".%ONE%."but now I understand it's use. Good thing for validating choices.
May 4, 200620 yr Yesterday, I though you had somehow managed to make a multi-lines variableWhat…like this!multivar.cmd
May 5, 200620 yr Author @Yzöwl, I'm pretty sure you've got it (although my brain is too narrow right now to figure out how it works exactly) but the FOR loop is not a very good demonstration:you could acheive the same displayed result with a single line %VAR%:::make VAR a slightly different wayFOR /F "DELIMS=" %%? IN (SIXLINE.TXT) DO SET VAR=!VAR!"%%~?"<SPACE here>::confirm VAR is monolineECHO %VAR%::still display it multilineFOR %%? IN (%VAR%) DO ECHO %%~?-please note the <SPACE> at the end of 'DO SET VAR=!VAR!"%%~?" '-to be integrated in the previous exampleAlso 'DO SET VAR=!VAR!"%%~?"^' followed by 2 empty lines does the trick without %LF%'s. And as in your example, it may be multiline as it can't be displayed properly by ECHO.Do you know of any other way to dump those variables so we can confirm their 'multitude' ?
Create an account or sign in to comment