I'm writing a batch file (as is typical) and there is an area code of that is not quite working the way I would like it to, so I'd like to "bracket" that area of code by "Echo On" and "Echo Off' statements to try to determine what is "going on". However, that area of code can also (potentially) make calls to a very-substantial but long-used and "proven" subroutine where I absolutely do not want echo to be "on". So, the "solution" to that problem is simple in principle: "Capture" the current echo state at the "top" of the subroutine and save it; turn echo "Off"; do my thing in the subroutine; and then restore "Echo" to its "original" state before exiting the subroutine, and I have code that does that and does, in fact, work but I consider it to be quite "ugly":
This works and isn't quite as bad as it could be because Z:, as often mentioned, is a RAM disk; but then I don't consider having to write the current echo status to a file and then read it back in to be at all an "optimal" solution.
Is there another, "better" way?
- Dan
P. S. And thank you again, Frank for reminding me about the "@Word..." functions. This is a perfect example of when its use can really simplify things.
Code:
:Subroutine
@Echo >!Z:\Temp\ExcludeLinesEchoStatus.%_PID.txt
@Echo Off
Echo This is just an Echo command to check whether the "Echo" command itself is echoed..
@Echo %@Word[2,%@Line[Z:\Temp\ExcludeLinesEchoStatus.%_PID.txt,0]]
@Del Z:\Temp\ExcludeLinesEchoStatus.%_PID.txt >NUL:
@Return
Is there another, "better" way?
- Dan
P. S. And thank you again, Frank for reminding me about the "@Word..." functions. This is a perfect example of when its use can really simplify things.