Computing.Net > Forums > Programming > passing variable to a call

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.

passing variable to a call

Reply to Message Icon

Name: mossvector
Date: June 22, 2005 at 00:28:18 Pacific
OS: xp pro
CPU/Ram: 3Ghz 1GB
Comment:

Hi,

Am working on a bat file to read lines out of a file and pass them to call1.bat:

FOR /F "delims=" %%a in (iplist.log) DO call call1.bat %%a

call1.bat is seeing %%a as %a - rather then as the line of text read from iplist and being passed to it.

Any suggestions on how I can get past this? Would be very much appreciated,

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 22, 2005 at 01:12:44 Pacific
Reply:

Hi Steve,

call1 needs to act on

%1

just as it would with a command line parameter.

Your:

call call1.bat %%a

is correct.

HTH


M2


If at first you don't succeed, you're about average.


0

Response Number 2
Name: mossvector
Date: June 22, 2005 at 01:50:57 Pacific
Reply:

it does not work though :(

My script is supposed to read lines out of the log file - which works fine, but when passed to another bat file ie. call1.bat - this sees %1 as %a, NOT the line of text its read from the log file.


0

Response Number 3
Name: Mechanix2Go
Date: June 22, 2005 at 02:43:38 Pacific
Reply:

Hi Steve,

I have no idea why you're getting that.

I tried this:

::**
FOR /F %%a in (iplist.log) DO call :1 %%a

goto :eof

:1

echo %1
pause
::**

Note that with NT you can CALL a label like a separate BAT.

In the script above I don't get %a ; I get the value.

BUT, I only get the first "word" of each line.

I get complete lines with this:

::**
@echo off
FOR /F "tokens=* delims= " %%a in (iplist.log) DO call :1 %%a

goto :eof

:1

echo %*
pause
::**

M2


If at first you don't succeed, you're about average.


0

Response Number 4
Name: mossvector
Date: June 22, 2005 at 04:39:18 Pacific
Reply:

M2,

Your right it works - my mistake!

I was using:
echo %aa
instead of:
echo %1

Thank you very much for all your help :)


0

Response Number 5
Name: Mechanix2Go
Date: June 22, 2005 at 04:50:40 Pacific
Reply:

Hi Steve,

Cool

M2


If at first you don't succeed, you're about average.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Beep in VB List traverse, batch (NT)



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: passing variable to a call

VC++ passing variables to a button www.computing.net/answers/programming/vc-passing-variables-to-a-button/13507.html

VC++ passing variables to a button www.computing.net/answers/programming/vc-passing-variables-to-a-button-/13487.html

Batch File Nested FOR variables www.computing.net/answers/programming/batch-file-nested-for-variables/15977.html