0

I don't know how to explain it, but i wanna do something like this:

@echo off
set test1=500
set test2=750
set /p view=
set show=%%view%%
echo %show%
pause

Basically I want to type in "test1" or "test2" and then the variable 'show' should set to %test1% (500) or %test2% (750), but it won't work for some reason. It always shows '%view%'. It should show up as '500' or '750'. Any help?

PS: I'm sorry, but I am bad at explaining stuff.

2 Answers2

1

You can use a IF condition to get this done like below

@echo off
set test1=500
set test2=750
set /p view=
if /I "%view%"=="test1" (set show=%test1%)
if /I "%view%"=="test2" (set show=%test2%)
echo %show%
Rahul
  • 76,197
  • 13
  • 71
  • 125
1

There are two possible ways:

call set show=%%%view%%%

or

setlocal EnableDelayedExpansion

set show=!%view%!

You may read full details about this management at this post.

Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108