Computing.Net > Forums > Disk Operating System > setting a dos variable from text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

setting a dos variable from text file

Reply to Message Icon

Name: Jeremy
Date: September 7, 2001 at 08:10:59 Pacific
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: September 8, 2001 at 09:00:55 Pacific
Reply:

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
Queen

Now, 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.bat

If 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


0

Response Number 2
Name: Eric
Date: October 16, 2001 at 16:42:44 Pacific
Reply:

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?


0

Response Number 3
Name: Michael
Date: February 2, 2002 at 03:34:21 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Search in variables How can i get DOS 6.22?



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: setting a dos variable from text file

Controlling A DOS Program From Windows www.computing.net/answers/dos/controlling-a-dos-program-from-windows/16993.html

read first line from text file www.computing.net/answers/dos/read-first-line-from-text-file/15066.html

Read in from text file www.computing.net/answers/dos/read-in-from-text-file/10895.html