Djé Posted May 2, 2006 Share Posted May 2, 2006 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted May 3, 2006 Share Posted May 3, 2006 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] Link to comment Share on other sites More sharing options...
gunsmokingman Posted May 3, 2006 Share Posted May 3, 2006 (edited) 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, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
Djé Posted May 3, 2006 Author Share Posted May 3, 2006 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... Link to comment Share on other sites More sharing options...
Djé Posted May 4, 2006 Author Share Posted May 4, 2006 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. Link to comment Share on other sites More sharing options...
Yzöwl Posted May 4, 2006 Share Posted May 4, 2006 Yesterday, I though you had somehow managed to make a multi-lines variableWhat…like this!multivar.cmd Link to comment Share on other sites More sharing options...
Djé Posted May 5, 2006 Author Share Posted May 5, 2006 @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' ? Link to comment Share on other sites More sharing options...
Djé Posted May 5, 2006 Author Share Posted May 5, 2006 Yzöwl, you were right Attached is a proof and an "application".multivar.cmd Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now