Please help meh, with variables

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Please help meh, with variables

#1 Post by MLGsuperGame414 » 10 Nov 2011 20:48

I need some help dim'ing my variables I have a test line of code for my ultimate project. I am new to the BATCH coding language. But not to BASIC and some C++ so I am not a complete noob.
Here is the line of code that I need help with,

@echo off
set var=%csname%
echo select option
Echo.
Echo 1). Keith
Echo 2). Martin
Echo.
set /p %csname%=Choose a name;
Echo %csname%
Pause

I want to get var to display in my batch file but when I run it nothing happens. I know I might be making it to complicated but I don't know how to go about it. Please help and thanks.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Please help meh, with variables

#2 Post by Ed Dyreen » 11 Nov 2011 04:55

'

Code: Select all

@echo off &SetLocal EnableDelayedExpansion

:§name.select ()
::(
   echo.select option
   echo.
   echo.1). Keith
   echo.2). Martin
   echo.
   set /p "$name=Choose a name:"
   set    "$names=Keith, Martin"
   set /a $count = 0
   for %%! in (

      %$names%

   ) do (
      set /a $count += 1
      if !$count! equ !$name! (
         set "$name=%%~!"
      )
   )
   echo.$name=!$name!_
   if !$name! equ +!$name! (
      goto :§name.select "()"
   )
::)

pause
exit /b

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Please help meh, with variables

#3 Post by MLGsuperGame414 » 11 Nov 2011 07:43

Thanks! :D

Post Reply