Computing.Net > Forums > Programming > getting a variable from batch 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.

getting a variable from batch file

Reply to Message Icon

Name: revanth84
Date: August 1, 2008 at 04:45:54 Pacific
OS: Windows XP
CPU/Ram: 1GB
Product: Professional
Comment:

How to get a return variable from the called batch-file ?

I'm having two batch files as follows

A.bat :
for /f "tokens=* delims=" %%a in (files.txt) do (
call B.bat var1 var2 var3
)

B.bat:
set var4=%1 + %2 - %3
REM some process like this
set var5=

I want to use var4 and var5 in A.bat
Is there a go?
I found the following URL relevant for this topic, but still no way out
http://www.marijn.org/archive/2006/...

Of all the things I've lost, I miss my Mind the most



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: August 1, 2008 at 06:17:19 Pacific
Reply:

if you can download gawk from here:
http://gnuwin32.sourceforge.net/pac...


{ print $1+$2-$3}

save the above as script.awk and on command line

c:\test> gawk -f script.awk file.txt


0

Response Number 2
Name: Razor2.3
Date: August 1, 2008 at 06:47:45 Pacific
Reply:

Command scripts are procedural and without boundaries for variables. You may use var4 and var5 in the first script after they're set in the second. (Assuming the second script doesn't use SETLOCAL, of course.)

EDIT: Never stopped me before.
VVVVVVVVVVVVVVVVVVVVVVVVVV


0

Response Number 3
Name: klint
Date: August 1, 2008 at 06:55:22 Pacific
Reply:

[Message deleted. Sorry. Razor got there first with the same information.]


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: getting a variable from batch file

passing a value to text file www.computing.net/answers/programming/passing-a-value-to-text-file-/18831.html

Nesting variables in batch files ? www.computing.net/answers/programming/nesting-variables-in-batch-files-/14334.html

How to return value from batch file www.computing.net/answers/programming/how-to-return-value-from-batch-file/17016.html