Hi Dostips community,
In response to the post on "New Technic" about the way to read multiple lines in a text file (note- it didn't work on my machine; I will post my issue on another topic) I wanted to find out if I could make my batch file set each line of a text file as a variable and make another variable that combines the data in the rest of the variables.
Then it should echo that variable.
Help will be greatly appreciated,
Rileyh
Combining contents of variables
Moderator: DosItHelp
Re: Combining contents of variables
Hi Rileyh,
what do you tried and at which line in your code you got problems?
jeb
what do you tried and at which line in your code you got problems?
jeb
Re: Combining contents of variables
Basically I am having trouble with all of it:
I cannot get it to echo the %line1% or any of them for that matter.
Code: Select all
< myfile.txt (
set /p line1=
set /p line2=
set /p line3=
set /p line4=
set /p line5=
)
set line
I cannot get it to echo the %line1% or any of them for that matter.
Re: Combining contents of variables
Hi,
I tested it with
And get the expected results, I can't see any problems.
jeb
I tested it with
Code: Select all
@echo off
( for /L %%n in (1 1 10) do echo This is line%%n ) > myfile.txt
< myfile.txt (
set /p line1=
set /p line2=
set /p line3=
set /p line4=
set /p line5=
)
set line
echo %line1%,%line2%,%line3%
And get the expected results, I can't see any problems.
jeb
Re: Combining contents of variables
Thanks jeb, it worked. You have to admit it is a cool technique, huh?
Re: Combining contents of variables
'
Yes it's cool, Jeb introduced it to us
respect.
Yes it's cool, Jeb introduced it to us

respect.