Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
Does anyone know how to set a dos variable using a field from a that is within a text file? I believe there might be a way using numbered variables, but I havent seen much doco on them. Examples would be a help.

Hi there. Examples from YOU would be a great help too =D
Watch this:
Let's say you've got the following text file (let's say the filename is "data.txt"):
Joker
King
QueenNow, for setting the variable CARD to the value "Joker", do this (via batch file):
fc data.txt nul /n |find "1:"> $out.txt
echo.>> $out.txt
date < $out.txt |find "1:"> $out.bat
echo SET CARD=%%5> enter.bat
call $out.bat
del $out.txt
del $out.bat
del enter.batIf you want the KING as the variable CARD, do this:
fc data.txt nul /n |find "2:"> $out.txt
echo.>> $out.txt
date < $out.txt |find "2:"> $out.bat
echo SET CARD=%%5> enter.bat
call $out.bat
del $out.txt
del $out.bat
del enter.bat
That's it.-- Secret_Doom --
secret_doom@hotmail.com
secretdoom.hpg.com.br

Hello,
I am trying to perform the exact same task as
Jeremy on a Windows 2000 box. While the
sample code above works great on my Windows
95 box, I am having trouble using it in
Windows 2000. When I run it there, it gives me an error stating that it cannot find a file or folder called nul. Any suggestions?

Of course this is the simplest thing to do, but Microsoft makes it almost impossible to work universally on all machines, since Bill "Nazi" Gates can't keep the contents of the Dos COMMAND directory stocked the same. Anyway, you'll need a dos utility called "ASET" or "ASET.EXE", and this will do everything you need with text from files. See also http://www.student.northpark.edu/pemente/sed/bat_env.htm for samples.

![]() |
Search in variables
|
How can i get DOS 6.22?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |