Welcome!

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

SignUp Now!

can a .BAT file know the name of the .BAT file that called it?

So you'll need to make sure that alias is defined in the new shell, e.g. through TCSTART.BTM. Or by using a global alias list.

I think the environment variables are not an issue, because the new shell will inherit from the old one. But I could be mistaken.
 
I kinda gave up and rolled back, because it doesn't seem easily achievable to add this one flourish to my situation, when the situation still functions without it. But I left it in there so if the %_callingfile variable is ever added, it will pick up on it and behave as if it was there. One can dream :D :D :D
 
So you'll need to make sure that alias is defined in the new shell, e.g. through TCSTART.BTM. Or by using a global alias list.
My tcstart always rereads my alias.lst :)

Mimicking unix commands in the 80s and 90s dos eras was one of my inspirations for using the command line that later became TCC :)
 
I'm trying to figure out how to do this in a plugin.

Okay, hooking CALL is easy enough. If the first argument does not begin with a colon, then we're calling a nested batch file and _CALLINGFILE needs to be updated. (If it does begin with a colon, then we're calling a subroutine and not a nested batch file, so _CALLINGFILE should not be updated.) And hooking QUIT is even easier. For bonus points, hook GOTO as well and check for GOTO :EOF, which is cmd‍.exe syntax.

But.... a batch file also ends when you hit the end of the file. And I'm not seeing any way for a plugin to catch that one. Anyone have a clever idea?
 
Off-topic but, @ClioCJS, how does your highlight.bat work? I'm jumping through hoops here and even then it only works sometimes and poorly!

1685981713550.png
 
Off-topic but, @ClioCJS, how does your highlight.bat work? I'm jumping through hoops here and even then it only works sometimes and poorly!

View attachment 3994

I use it a lot for secondary highlighting, sort of a psuedogrep.
I became frustrated with trying to make grep do this.
I also think it's a bit easier to use than grep's GREP_COLORS environment variable that was recently deprecated to GREP_COLOR and dealing with all that is just a hassle (but nice with you grep with --color=always aliased i).

But yea, ANSI in windows console is horrible inconsistent. I can do the "up arrow enter" thing to rapidly repeat a command and ANSI output will be corrupted in certain situations/commands, like, 1 out of 3-5 times.

The reason why it's not perfect in TCC is because Windows handles it, lol.

Maybe try enabling experimental console in the options?

1685983468407.png
 
How does it work? Please show a sed command line.
Certainly :)

assuming %SEARCHFOR is your regex, it works like this:

Code:
sed '/%SEARCHFOR/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'


1685985254192.png
 
I'm trying to figure out how to do this in a plugin.

Okay, hooking CALL is easy enough. If the first argument does not begin with a colon, then we're calling a nested batch file and _CALLINGFILE needs to be updated. (If it does begin with a colon, then we're calling a subroutine and not a nested batch file, so _CALLINGFILE should not be updated.) And hooking QUIT is even easier. For bonus points, hook GOTO as well and check for GOTO :EOF, which is cmd‍.exe syntax.

But.... a batch file also ends when you hit the end of the file. And I'm not seeing any way for a plugin to catch that one. Anyone have a clever idea?

I had no idea you could call subroutines, wow.
 
I had no idea you could call subroutines, wow.
That won't work if you want the subroutine to return something. I use %@exec[gosub subroutine].

Code:
v:\> type subrtest.btm
echo subr returned %@exec[gosub subr]
quit

:subr
return 666

v:\> subrtest.btm
subr returned 666
 
Back
Top
[FOX] Ultimate Translator
Translate