Is it possible to add another command, same line as CALL :
Moderator: DosItHelp
Is it possible to add another command, same line as CALL :
In the below call command, is there anyway to add a completely different command on the same line; or, is everything after the call label treated as respective parameters?
I am guessing there is no way. But just wanted to be certain.
Call :subroutine &echo subroutine complete
I am guessing there is no way. But just wanted to be certain.
Call :subroutine &echo subroutine complete
Re: Is it possible to add another command, same line as CALL
Did you try this?
(Call :subroutine ) & echo subroutine complete
(Call :subroutine ) & echo subroutine complete
Re: Is it possible to add another command, same line as CALL
I doubt it, he didn't even tried his own code.foxidrive wrote:Did you try this?
(Call :subroutine ) & echo subroutine complete
Please run your code, post us your valuable conclusion/s and shed some light on us.MKANET wrote:Call :subroutine &echo subroutine complete
Thanks,

Re: Is it possible to add another command, same line as CALL
I should have probably rephrased my question. I was hoping to run a subsequent command after it completes processing the subroutine. I've never been able to do that; but, thought maybe there is a way to do it.
Ed Dyreen wrote:I doubt it, he didn't even tried his own code.foxidrive wrote:Did you try this?
(Call :subroutine ) & echo subroutine completePlease run your code, post us your valuable conclusion/s and shed some light on us.MKANET wrote:Call :subroutine &echo subroutine complete
Thanks,
Re: Is it possible to add another command, same line as CALL
MKANET wrote:I should have probably rephrased my question. I was hoping to run a subsequent command after it completes processing the subroutine. I've never been able to do that; but, thought maybe there is a way to do it.
Have you run your code yet?
Re: Is it possible to add another command, same line as CALL
Yes, I was hoping that went without saying since I already clarified what I was trying to do (what you quoted). If it still doesn't make sense, below is an updated example.
If I have everything after the & on a separate line, %converted% is shown. Otherwise, it's still undefined..
If I have everything after the & on a separate line, %converted% is shown. Otherwise, it's still undefined..
Code: Select all
call :Converter &echo Converted value is %converted%
foxidrive wrote:MKANET wrote:I should have probably rephrased my question. I was hoping to run a subsequent command after it completes processing the subroutine. I've never been able to do that; but, thought maybe there is a way to do it.
Have you run your code yet?
Re: Is it possible to add another command, same line as CALL
No, I disagree, the previous exemplary code didn't exhibit any problem.MKANET wrote:Yes, I was hoping that went without saying since I already clarified what I was trying to do (what you quoted).
But the new code you now present us with ( which is totally different ) does.MKANET wrote:Call :subroutine &echo subroutine complete
Your problem is immediate expansion. Variables are being replaced by their content while the line is read.MKANET wrote:Code: Select all
call :Converter &echo Converted value is %converted%
What u want is delayed expansion. Variables are being replaced by their content while the line is executed.
Code: Select all
setlocal enableDelayedExpansion
setlocal /?
pause
call :Converter &echo Converted value is !converted!
pause

Re: Is it possible to add another command, same line as CALL
Here you are MKA. Try this and then look at your posts.
It is obvious you *didn't* try your code.
It is obvious you *didn't* try your code.
Code: Select all
@echo off
Call :subroutine &echo subroutine complete
pause
goto :EOF
:subroutine
echo hello world
Re: Is it possible to add another command, same line as CALL
Hmmm... interesting. I thought for sure my second post clarified what I was actually having trouble with. I guess it didn't go without saying after all that I wasn't talking about the original example anymore
I think what confused me is already had a setlocal enableDelayedExpansion in the beginning of my batch file. But thanks, at least now I know what its related to.
I think what confused me is already had a setlocal enableDelayedExpansion in the beginning of my batch file. But thanks, at least now I know what its related to.
Ed Dyreen wrote:No, I disagree, the previous exemplary code didn't exhibition any problem.MKANET wrote:Yes, I was hoping that went without saying since I already clarified what I was trying to do (what you quoted).But the new code you now present us with ( which is totally different ) does.MKANET wrote:Call :subroutine &echo subroutine complete
Your problem is immediate expansion. Variables are being replaced by their content while the line is read.What u are after is delayed expansion. Variables are being replaced by their content while the line is executed.Code: Select all
call :Converter &echo Converted value is %converted%
Don't blame me, I put as much time in formulating an answer, as you put time in formulating a good question.Code: Select all
setlocal enableDelayedExpansion
setlocal /?
pause
call :Converter &echo Converted value is !converted!
pause
Re: Is it possible to add another command, same line as CALL
MKANET wrote:Hmmm... interesting. I thought for sure my second post clarified what I was actually having trouble with. I guess it didn't go without saying after all that I wasn't talking about the original example anymore
I think what confused me is already had a setlocal enableDelayedExpansion in the beginning of my batch file. But thanks, at least now I know what its related to.
You said NOTHING about using a variable in either of your first two posts. Using Delayed Expansion has also been explained to you a few times since you joined the forums.
If you read other threads on this forum you will see plenty of users on this forum tell other users that their questions need to be accurate with their REAL DATA! That means the batch file you are using and any other subsequent input you are using with the batch file. If you don't give us accurate DATA you get an inaccurate answer and waste everyone's time.