Computing.Net > Forums > Programming > batch: copy one var to another

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.

batch: copy one var to another

Reply to Message Icon

Name: zintazu
Date: January 12, 2004 at 01:46:45 Pacific
OS: Win98 (DOS)
CPU/Ram: P4 512 RAM
Comment:

Hi,

I have a variable called %venid% which a program makes with 4 numbers in it e.g 8086, which I have another program uses to read from a ini file. My problem is that the second program then makes a variable called the 4 numbers e.g 8086 and have for example c:\driver\intel in it. The only place where the 4 numbers are standing is in the venid var. and I need to somehow get them so I can read the string in the e.g 8086 var.

I have tried with the following, but it seems like it will not work when the var. is made by numbers.

venid=8086
8086=c:\drivers\intel

set driver=%%%venid%%%

if the content in the venid are numbers e.g 8086 it do not work. But if the content are e.h hello and I got a var. called hello with the content hello=c:\drivers\intel, then the driver var. will be driver=c:\drivers\intel.
When the venid is = 8086 then the driver var. will be driver=%8086%.

I need the driver var. to have the content of the 4 numbers var.

Hope that someone can help me.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: January 12, 2004 at 04:58:04 Pacific
Reply:

Here the batch to do the trick; I tested it under plain DOS 6.22 and worked fine. It relies on the property of batch files to interpret the = character after the filename as a separator like blank.

@Echo Off

Rem The following two lines to setup a test case
Rem ---------------------
Set venid=8086
Set 8086=C:\drivers\intel
Rem ---------------------

Echo Set driver=%%1 > %venid%.bat
Set | Find "%venid%=" > %0$1.bat
Call %0$1

Del %0$1.bat
Del %venid%.bat
Echo driver=%driver%


0

Response Number 2
Name: zintazu
Date: January 12, 2004 at 07:34:52 Pacific
Reply:

Set | Find "%venid%=" > %0$1.bat

don't work it says that its a wrong command or file name.

Are there any .exe or .com files from dos I need to get it to work ?? it's running on a normal win98 dos boot disk.



0

Response Number 3
Name: IVO
Date: January 12, 2004 at 07:52:44 Pacific
Reply:

It's unlike a bootdisk has Find.exe (external) command on it, as it is not one of the standard commands required to accomplish any boot related task (as Fdisk, Sys and others are).
You can find "Find.exe" in the C:\Windows\Command directory on the hard disk and copy it onto your boot diskette.


0

Response Number 4
Name: zintazu
Date: January 12, 2004 at 23:06:40 Pacific
Reply:

Thanks,
It works great, thank you very much :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch: copy one var to another

Batch File backup to another source www.computing.net/answers/programming/batch-file-backup-to-another-source/18637.html

Batch to insert column from one csv to anothe www.computing.net/answers/programming/batch-to-insert-column-from-one-csv-to-anothe/20079.html

Batch copy and rename if needed www.computing.net/answers/programming/batch-copy-and-rename-if-needed/14747.html