mf_2 Posted July 4, 2007 Posted July 4, 2007 Hello,I have the following batch file:SET %one% = "test"SET %two% = "program"Now I want %three% to contain somethign like this:SomeWordstestprogramThat means that I want to have a string, attach %one% and then %two% to it and then write it into %three%.How is that possible?I tried PHP syntax but that didn't work
mf_2 Posted July 4, 2007 Author Posted July 4, 2007 Hello,This worked:SET three = "SomeWord" + %one% + %two%However, when I want to see whats in %three%, I don't get anything.echo %three%gives me"echo is turned ON"or something like that (it's a German Windows, so I had to translate it).What am I doing wrong?
mormoloc Posted July 4, 2007 Posted July 4, 2007 i found THIS for you i never worked with batch commands but looking at some examples, i think you should try like this:SET one = string1SET two = string2SET three = "some other string " + one + " " + two ECHO %three%
[deXter] Posted July 4, 2007 Posted July 4, 2007 (edited) You've got the wrong syntax for SET.The correct syntax is: SET variable=stringSET one=testSET two=programSET three=SomeWord%one%%two%echo %one%echo %two%echo %three% Edited July 4, 2007 by [deXter]
spacesurfer Posted July 4, 2007 Posted July 4, 2007 (edited) set three = someword%one%%two%echo %three%leave no spaces and exclude "+" between %one% and %two%.Edit: dexter beat me to it. Edited July 4, 2007 by spacesurfer
mf_2 Posted July 4, 2007 Author Posted July 4, 2007 Thanks for the link, this finally worked:SET THREE = SomeWords%one%%two%SET THREEThe second line is used instead of the echo command.
NaDer_GenKO Posted July 4, 2007 Posted July 4, 2007 (edited) thank You very very much 'mormoloc' I was looking for a site like this Edited July 4, 2007 by NaDer_GenKO
Yzöwl Posted July 4, 2007 Posted July 4, 2007 Good practice notes:Set your variables local to the running batch sessionTo prevent the inclusion of unwanted whitespace in your variables, enclose them in parentheses (lines 3, 4, 5)@Echo OffSetlocal(Set one=test)(Set two=program)(Set three=SomeWords%one%%two%)Echo/%%three%%=%three%
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now