Assigning a string to a variable

February 1, 2010 at 23:35:42
Specs: Windows 7
Hi all,

I'm planning to assign a alphanumeric value to a variable in batch.. but throwing error messages

setlocal
set /A test = \765514e2aad02ca658cc56cdb7884947 *E:\\test1

echo %test%
endlocal

Error message:
C:\Users\bgannu>E:\DIverf.bat

C:\Users\bgannu>setlocal

C:\Users\bgannu>set /A test = \765514e2aad02ca658cc56cdb7884947 *E:\\test1

C:\Users\bgannu>echo 0
0

C:\Users\bgannu>endlocal


See More: Assigning a string to a variable

Report •


#1
February 1, 2010 at 23:55:20
I suggest you go to the command line and type in "set /?"

set /a is for simple arithmetic, it assumes that alphanumeric
strings are variable names numbers reside in, if the variable
is unused or an invalid number zero is used.

What you want is plain old set:

rem for plain set don't add whitespace before
rem or after the equals sign, unless you want
rem your variable name/value to contain that
rem space.
set test=\765514e2aad02ca658cc56cdb7884947 


Batch Variable how to


Report •

#2
February 3, 2010 at 08:40:10
> set /A test = \765514e2aad02ca658cc56cdb7884947
> *E:\\test1
>

That's not a numeric expression ... check out SET /?


Report •

#3
February 3, 2010 at 21:31:46
Hi folks,

I am very new to batch programming & looking for your co-operation...

I have in my 'compile_schema.txt' following data

LS001/m_m_001_01/m_001_01_01_co.fla
LS001/m_m_001_01/m_001_01_02_co.fla
LS001/m_m_001_01/m_001_01_03_co.fla

line by line i want to break this data line wise & print like as follow in DOS when i will run batch file

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml


here want i have done & still what with i strugling

for /f "tokens=1,2 delims=/" %%a in (compile_schema.txt) do ( echo BUILDFILE %%a/build_%%b.xml )

this gives

following when i run file batch file :

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml

But iwant it should give Outfut

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml

looking for reply...

Regards,
Ganesh


Report •

Related Solutions


Ask Question