Welcome!

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

SignUp Now!

Debugging a LIBRARY function

Aug
1,904
68
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
 
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).
 
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".
 
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
 
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.
 
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?
 
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

Back
Top