Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Name of current running gosub routine?

Dec
21
2
If I used the call label construction the name of the running 'routine' is in the variable %0.

Is there a same mechanism if we using gosub subroutines?
I could not find an internal variable for this purpose , but maybe I missed it.

A workaround I use now is an alias for gosub and parsing the name of the gosub routine as the first parameter.
An internal variable with the gosub routine name seems a nicer/cleaner solution.
 
Would this be a solution for you?

Code:
@SETLOCAL
@ECHO OFF
set _gosub=TryIt & gosub %_gosub
ENDLOCAL
quit

:TryIt
echo Entered %_gosub Subroutine
Return

Output;

Code:
R:\>test.btm
Entered TryIt Subroutine

Joe
 
Would this be a solution for you?

Code:
@SETLOCAL
@ECHO OFF
set _gosub=TryIt & gosub %_gosub
ENDLOCAL
quit

:TryIt
echo Entered %_gosub Subroutine
Return

Output;

Code:
R:\>test.btm
Entered TryIt Subroutine

Joe
As a workaround this is a good solution.
Thanks.
 
New in v32;

_BATCHLABEL returns the name of the current GOSUB subroutine.
(Or an empty string if not in a subroutine.)
 
Back
Top
[FOX] Ultimate Translator
Translate