Debugging a LIBRARY function

This script;
Code:
@setlocal
@echo off
ver
library /u /r %0
set kount=0
Sub1
echo From %0: %kount
endlocal
quit

Sub1 {
set kount=%@eval[%kount+1]
echo From Sub1: %kount
}

Works as it should when run from TCC;
Code:
c:\users\jlc\utils>test.btm

TCC  22.00.25 x64   Windows 7 [Version 6.1.7601]
From Sub1: 1
From test.btm: 1

...but when running from BDEBUGGER, I get a
Code:
"Sub1 was not found"
when stepping through the code.

When running from BDEBUGGER without stepping through the code, same result.

Joe
 
May 20, 2008
11,415
99
Syracuse, NY, USA
I'm a bit baffled why you would want to do this.

But I can't reproduce your error - it works fine here.
Debug a BTM that calls a library function? ... what's so odd about that?

I get the same result as Joe. The text in the editor disappears (as if it's going to show me Sub1) and
---------------------------
IDE 22
---------------------------
Sub1 was not found.
---------------------------
OK
---------------------------
That said, Sub1 **is** executed (I see its output).
 

rconn

Administrator
Staff member
May 14, 2008
12,364
150
Debug a BTM that calls a library function? ... what's so odd about that?

That's not the odd part; it's that he's combining the BTM and the library function in the same file, reloading the file to read the library function, and assuming that the parser & debugger will only try to run the appropriate parts.

In effect, he's nesting a batch file inside itself, something the debugger does *not* like.

And the debugger is a "batch debugger", not a "batch / library / alias debugger".
 
May 20, 2008
11,415
99
Syracuse, NY, USA
Here it is again, a little tidier. I stepped all the way through the BTM. The library functions are lost when IDE starts.

upload_2017-12-7_22-54-58.png
 

rconn

Administrator
Staff member
May 14, 2008
12,364
150
Here it is again, a little tidier. I stepped all the way through the BTM. The library functions are lost when IDE starts.

WAD. The batch debugger uses the same window for output, but it is a different session.

The batch debugger starts in a clean environment - it does not inherit batch file settings (i.e., from a calling batch file), and it does not inherit library functions.
 
May 20, 2008
11,415
99
Syracuse, NY, USA
WAD. The batch debugger uses the same window for output, but it is a different session.

The batch debugger starts in a clean environment - it does not inherit batch file settings (i.e., from a calling batch file), and it does not inherit library functions.
Shouldn't that different session load library functions?
 
May 20, 2008
11,415
99
Syracuse, NY, USA
If they're in your default library directory.

But it's a bad idea to write batch files that are dependent on the state of your machine at the time you debugged them.

They ARE in the default place (<install_dir>\Library), but they're not available when debugging.

Whatever is in the default library directory is automatic. I know it will always be loaded when I run TCC (but not when I debug).

If I'm way off base, let's go back to square one. How do you debug BTMs which use library functions?
 
While still hoping for the ability to Debug BTMs which use library functions, I have a temporary solution;
Code:
@setlocal
@echo off
ver
library /u /r %0.btm
set kount=0
Sub1
echo From %0: %kount
endlocal
quit

Sub1 {
set kount=%@eval[%kount+1]
@echo %@debug[Called from Sub1: %kount] > nul:
echo From Sub1: %kount
}

When I execute the .BTM from TCC, I can view the output of the library (via @DEBUG) using DebugView.

Joe
 
Similar threads
Thread starter Title Forum Replies Date
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
T Is there a way to maintain the position in the environment list, while debugging? Support 10
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
S Debugging Session Hang Support 7
I Change value of a variable while debugging Support 3
C How to? run a batch file in administrator mode while debugging in take command software Support 1
Mordachai Help! How to set parameters for script I'm debugging?! Support 6
Vasilich How to? debugging files that use CALL command - possible?? Support 3
Stefano Piccardi forum software writes debugging output Support 5
S V10 debugging problems Support 9
D Version 28 LIBRARY changes have side effects Support 1
Joe Caverly LIBRARY /F in v28 Support 0
Joe Caverly LIBRARY and Pipes Support 2
Joe Caverly How to? Get name of current LIBRARY function? Support 4
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
vefatica Continued lines (^) in a library routine? Support 5
vefatica LIBRARY and file name completion? Support 4
vefatica '}' in a library function? Support 3
vefatica Library functions and line continuations? Support 4
Joe Caverly @NAME supports library functions Support 2
Joe Caverly Update ENDLOCAL to include LIBRARY Support 0
J Documentation Make tcc great again - what's the benefit of LIBRARY? Support 6
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
x13 WeekNum function? Support 3
C email[string] function Support 10
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
Dick Johnson Using the @instr function Support 5
D Can the argument to RETURN be a function expansion? Support 3
J Trouble with @full[] function. Support 3
Fross Quick Function Question Support 17
vefatica Quoting @Function parameters? Support 0
Steve Pitts Documentation @CAPI function summary Support 0
x13 %x$ in function Support 3
thorntonpg @eval function, interesting results any explanation? Support 3
x13 Function to get interface user-defined name? Support 10
vefatica Fixed Help @FUNCTION, missing paragraph Support 8
Mordachai Variable followed by function constantly failing... Support 5
nickles Call a complex function Support 13
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
R Function #IDOW returns only 2 characters Support 10
T scrput `` in alias or function Support 2
S International characters - TYPE vs %@LINE function Support 5
JohnQSmith WAD @REPEAT function Support 15
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
A pdir function usage Support 3
nikbackm FUNCTION with variable number of arguments Support 17

Similar threads