Call a complex function

Jun 24, 2008
223
0
Siegen, Germany
Nope. The function I'd like to use is too complex for a standard function (it's a Git prompt - like I use it in bash). I'm looking for method to produce a new string before the prompt returns, and PROMPT just spitting out that string. Linux btw. does it by providing a callback hook ($PROMPT_COMMAND). But in TCC I haven't seen anything the like.
 
May 20, 2008
11,414
99
Syracuse, NY, USA
($PROMPT_COMMAND) ... that would seem about the same as
Code:
set prompt=%%@execstr[complicated.BTM]
 
May 20, 2008
11,414
99
Syracuse, NY, USA
You might also try the special alias POST_EXEC. Being an alias, it can have several commands (separated by "&"), or it can execute complicated.btm. In any event, if POST_EXEC creates my_prompt_string and then (lastly) does "SET PROMPT=my_prompt_string", it should work.
 
Jun 24, 2008
223
0
Siegen, Germany
@charles
Wasn't aware that %@execstr[] could call BTM files. However this seems to be slower than using the alias approach (@Rex: could you comment on this?). Also, this approach suffers from the below problem too.

@vince
Unfortunately setting PROMPT in tcstart.btm seems to be treated differently. Setting PROMPT from the command line (e.g. set prompt=%_PID%$s%%git_prompt%%$g$s) works (set PROMPT gives me: <some_pid>$s%git_prompt%$g$s); setting PROMPT in tcstart.btm (same assignment) doesn't work (set PROMPT gives me: <some_pid>$s$g$s), the variable gets eliminated.
I also tried `%...%`, ^%...^%,`%%...%%`, and ^%^%...^%^%, to no avail.
 
May 20, 2008
11,414
99
Syracuse, NY, USA
This should work in both places:
Code:
SET PROMPT=%[_PID]$s%%[git_prompt]$g$s
The value of git_prompt will be an empty string if it isn't defined. If it becomes defined, a non-empty string will appear.
Code:
2244 > type %_tcstart | grep git
SET PROMPT=%[_PID]$s%%[git_prompt]$g$s

2244 > set prompt
2244$s%[git_prompt]$g$s

2244 > set git_prompt=foo

2244 foo>
 
Jun 24, 2008
223
0
Siegen, Germany
@vince
Seems my understandig of %s to reference variables was too CMD-bound. %[...] obviously behaves like ${...} in the bash; wasn't aware of that...

One ugliness remains though: when starting a new TCC session, POST_EXEC is not executed prior to the first prompt. Of course one might argue "No command was executed before this first prompt", and would be correct. It would be nice however, to have the desired information right in the first prompt i.e. w/o having to resort to call the POST_EXEC alias manually once.

@all
Thanks for your help!
 
May 29, 2008
571
4
Groton, CT
This seems to work for me:
Code:
if isalias post_exec post_exec
as the last command of TCSTART.BAT (or .BTM).
 
Similar threads
Thread starter Title Forum Replies Date
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
EDerH Powershell call from script Support 24
S Debugger Bat file call history Support 9
F Powershell call fails with "Scripting Integrator 2016 (PowerShell)" license error Support 9
M Call History popup-window? Support 0
rconn News Take Command v19 Call for Features Support 0
cgunhouse Problem with CALL and Directory Aliases in V17 Support 9
Vasilich How to? debugging files that use CALL command - possible?? Support 3
noahcoad Option to always CALL? Support 4
M @ExecStr vs. Call Support 4
O CALL SYSTEM from Fortran Support 4
rconn Last call for v12 feature requests Support 59
rconn Call for v11 feature requests Support 35
p.f.moore Running another batch file without CALL Support 7
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Joe Caverly How to? Get name of current LIBRARY function? Support 4
x13 WeekNum function? Support 3
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
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
vefatica '}' in a library function? Support 3
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
Joe Caverly Debugging a LIBRARY function Support 10
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
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
S %@REGQUERY function Support 1
Dan Glynhampton Documentation v15 help: Error on @TRIMALL function page Support 0
M Why doesn't this @Field function work? Support 0
fpefpe How to? user function Support 1
M Why is this function getting these results in these circumstances? Support 6
A WAD function return values with parentheses prevent evaluation of additional functions Support 31

Similar threads