Page 1 of 1

batch programming help

Posted: 08 Jul 2013 07:26
by vvomble
wondered if you could help

hopefully you can tell what I'm doing with this:

:hexvalues
set /p hex1=02ac08
set /p hex2=953fcd
set /p hex3=fb0ca6
set /p hex4=69fa87
set /p hex5=34bae9

I want is so that when I put %hex1% etc after an echo is will show as 02ac08

I don't think this is correct but this is the first time i've had a go at batch programming.

If you could explain in lamen's terms that would be better still

Re: batch programming help

Posted: 08 Jul 2013 09:13
by Sponge Belly
Hello VVomble! :-)

Um… what’s wrong with… ?

Code: Select all

set "hex1=02ac08"
echo(%hex1%


Or am I missing something? And why are you using set /p? What are you trying to achieve? Please explain your task in more detail.

- SB

Re: batch programming help

Posted: 08 Jul 2013 09:20
by penpen
You are using the set command with the /p option:
set /p hex1=02ac08

With this command line, you have instructed the command processor to show
the black text within the shell and then to prompt the user for input. The user
then may type in some characters and finalize the input by pressing the return
key, or the user may abort in various ways. The text you have typed in is then
stored into the variable hex1; if you haven't typed in text, the variable remains
unchanged.

What you want to do is just assign 02ac08 to hex1.
For this you should use the parameterless set command:

Code: Select all

set hex1=02ac08

penpen

Edited: Sry the syntax highlighting took longer than thought.

Re: batch programming help

Posted: 08 Jul 2013 09:22
by vvomble
That worked perfectly, I'm just playing with a basic script i found on the net and set /p was used after inputs I wasn't sure if that was the correct way to set it (although it wasn't working but it's now sorted thanks a million