/set command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Euvarios
Posts: 1
Joined: 10 Nov 2014 09:40

/set command

#1 Post by Euvarios » 10 Nov 2014 09:45

Hello, I'm beginner and I have one problem, I want to do menu like :

MENU
-------------------------------------
%A%
%B%
%C%
-------------------------------------
%D%
%E%
-------------------------------------


And I want put it into %menu%, but I don't know how to /set that with this spacing... Help

Edit, ok I want put this :

" MENU
-------------------------------------
%A%
%B%
%C%
-------------------------------------
%D%
%E%
------------------------------------- "

into variable %menu%
And when I write :

Echo %menu%

I will have :

MENU
-------------------------------------
%A%
%B%
%C%
-------------------------------------
%D%
%E%
-------------------------------------

Like /set something=I like potatoe
and when I write
Echo %something%
I will have :
I like potatoe

That's all, sorry i can't explain it easie, I hope you will understand...
Last edited by Euvarios on 10 Nov 2014 09:59, edited 1 time in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: /set command

#2 Post by Squashman » 10 Nov 2014 09:48

You are going to have to explain with a lot more detail what you are trying to accomplish. Please show some examples as well.

Thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: /set command

#3 Post by foxidrive » 10 Nov 2014 10:17

Are you are asking how to put an entire menu in a single variable?
That's not the usual way to do it in a batch file.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: /set command

#4 Post by penpen » 10 Nov 2014 13:07

I'm not sure, but it could also be that you (Euvarios) want(s) to have a dynamic menue without redefining it.
If this is true, this might help you (tested on WinXP home 32 bit):

Code: Select all

@echo off
setlocal disableDelayedExpansion enableExtensions
set LF=^


set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"

set ^"menu=MENU^^^%LF%%LF%^%LF%%LF%^^%\n%
-------------------------------------^^^%LF%%LF%^%LF%%LF%^^%\n%
!A!^^^%LF%%LF%^%LF%%LF%^^%\n%
!B!^^^%LF%%LF%^%LF%%LF%^^%\n%
!C!^^^%LF%%LF%^%LF%%LF%^^%\n%
-------------------------------------^^^%LF%%LF%^%LF%%LF%^^%\n%
!D!^^^%LF%%LF%^%LF%%LF%^^%\n%
!E!^^^%LF%%LF%^%LF%%LF%^^%\n%
-------------------------------------^"

echo(
echo( Menu definition:
echo(

set "A="
set "B="
set "C="
set "D="
set "E="

echo %menu%


setlocal enableDelayedExpansion

echo(
echo( Menu Variation 1
echo(

set A=Menuitem 1
set B=Menuitem 2
set C=Menuitem 3
set D=Menuitem 4
set E=Menuitem 5

echo %menu%


echo(
echo( Menu Variation 2
echo(

set A=1. Menuitem
set B=2. Menuitem
set C=3. Menuitem
set D=4. Menuitem
set E=5. Menuitem

echo %menu%

endlocal
endlocal
goto :eof

penpen

Post Reply