mf_2 Posted July 4, 2007 Share 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 Link to comment Share on other sites More sharing options...
mormoloc Posted July 4, 2007 Share Posted July 4, 2007 SET %three% = "SomeWord" + %one% + %two% ??? Link to comment Share on other sites More sharing options...
mf_2 Posted July 4, 2007 Author Share 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? Link to comment Share on other sites More sharing options...
mormoloc Posted July 4, 2007 Share 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% Link to comment Share on other sites More sharing options...
[deXter] Posted July 4, 2007 Share 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] Link to comment Share on other sites More sharing options...
spacesurfer Posted July 4, 2007 Share 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 Link to comment Share on other sites More sharing options...
mf_2 Posted July 4, 2007 Author Share 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. Link to comment Share on other sites More sharing options...
NaDer_GenKO Posted July 4, 2007 Share 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted July 4, 2007 Share 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% Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now