Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Batch: dynamic variable assignation & evaluation

Featured Replies

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


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]

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 by gunsmokingman

  • Author

Thanks dudes.

Yzöwl, I'm too tired for tonight and really could not grab the entire mechanism yet. :wacko:

But I'm suspecting you acheived something great... :w00t:

I'll have to investigate tomorrow morning with a good coffee...

  • Author

In Choice.cmd, in order to get rid of the quotes in the displayed strings we can use:

:SETVALUES
SET %TYPE%%I%=%~1
GOTO :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 :w00t:, because of:

ECHO/.%PICK% |FINDSTR/C:".%ONE%."

but now I understand it's use. Good thing for validating choices.

  • 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 way
FOR /F "DELIMS=" %%? IN (SIXLINE.TXT) DO SET VAR=!VAR!"%%~?"<SPACE here>
::confirm VAR is monoline
ECHO %VAR%
::still display it multiline
FOR %%? IN (%VAR%) DO ECHO %%~?

-please note the <SPACE> at the end of 'DO SET VAR=!VAR!"%%~?" '

-to be integrated in the previous example

Also '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' :unsure: ?

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.