i have common .bat file reads status.xml file , finds out value of status field. batch file called other batch files finding out status value. calling batch files send file name common bat file. not able send status common batch file calling batch files. can please help?
main batch file -- call common bat file , send file name , variable arguments setlocal call common.bat c:\folderdir\files\status.xml val1 -- trying print status returned common bat file echo [%val1%] common batch file @echo off setlocal enabledelayedexpansion rem loop through file , read value of status tag (for /f "delims=" %%a in (%1) ( set "line=%%a" set "newline=!line:<interface_status>=!" set "newline=!newline:</interface_status>=!" if "!newline!" neq "!line!" ( @echo status !newline! rem want send`enter code here` value of newline calling batch file set %~2 = !newline! <--this not work ) ))
within setlocal/endlocal bracket (where eof=endlocal) changes made environment backed out.
you need set variable within common.bat visible after final close-parenthesis (ie. return value - , empty string.
then, in line after common.bat's final close-parenthesis, put line:
endlocal&set %~2=%returnvalue% where returnvalue contains er, value wish return (funny, that...)
btw: string set space-sensitive. had line worked, have been setting variable "var1 " - not "var1" - space before = have been included in variable name - , spaces after = likewise included in value assigned.
the syntax
set "var=value" is used exclude stray trailing spaces on line (as may left editors)
(sigh)...
@echo off setlocal enabledelayedexpansion rem loop through file , read value of status tag (for /f "delims=" %%a in (%1) ( set "line=%%a" set "newline=!line:<interface_status>=!" set "newline=!newline:</interface_status>=!" if "!newline!" neq "!line!" ( @echo status !newline! rem set return value set returnvalue=!newline! ) )) endlocal&set %~2=%returnvalue%
Comments
Post a Comment