By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!E:\Utils>echo %@path[%_cmdspec]
C:\Program Files\JPSoft\TCMD32\
cdd %comspec%\.. is fine enough for me.
Thanks, @samintz. You're right about that. And thanks @Joe Caverly and @Rodolfo. If I ever used _CMDSPEC it had to be a couple decades ago.I think @Joe Caverly's use of _cmdspec vs COMSPEC is better IMO. COMSPEC is just an environment variable that can be changed even though you are running TCC. The internal variable will always point to TCC.
I couldn't figure out a nice way to use the internal TCEDIT command and wait for the editor to exit (without getting a second instance of TCC).
@setlocal
@echo off
path /n | tcedit
waitfor tcedit
endlocal
Too hard!Hey @vefatica,
Could you do something like this;
Code:path /n | tcedit
Modify the path in TCEdit,
save to STDOUT,
and then do something with it?
View attachment 4420
Joe
I don't follow that. How does anything get into CLIP:?For a lot of these one-off types of things, I use the clipboard.
Code:path /n | tcedit do p in @clip: (set newp=%newp;%p) set PATH=%@right[-1,%newp]
You would edit in TCEDIT, then Ctrl+A, Ctrl+C. Then exit TCEDIT. I just showed the steps I take. You would need a waitfor before the do if you were to put that in a BTM or library.I don't follow that. How does anything get into CLIP:?
OK, I get it now. That's too much for the user to remember. I have this (so far). No doubt, there will be more changes.You would edit in TCEDIT, then Ctrl+A, Ctrl+C. Then exit TCEDIT. I just showed the steps I take. You would need a waitfor before the do if you were to put that in a BTM or library.
:: PATHEDIT.BTM
setlocal
if "%1" == "/?" goto syntax
if "%1" == "/A" (shift & goto append)
if "%1" == "/P" (shift & goto prepend)
set before=%temp\pathedit_before.tmp
set after=%temp\pathedit_after.tmp
path /n > %before
start /wait /pgm "%@path[%_cmdspec]\tcedit.exe" %before
:: below, the second replace gets rid of a
:: trailing ';' which could be just left there
tpipe ^
/input=%before ^
/output=%after ^
/replace=0,0,0,0,0,0,0,0,0,\r\n,; ^
/replace=4,0,0,0,0,0,0,0,0,";\Z",""
set path=%@line[%after,0]
goto done
:append
:: don't add a second ';' (not really necessary)
set semicolon=%@if["%@right[1,%path]" == ";",,;]
set path=%[path]%[semicolon]%1$
goto done
:prepend
set path=%1$;%path
goto done
:syntax
echo Usage: PATHEDIT.BTM [[/A(ppend) ^| /P(repend)] string]^r^n
echo ^tWithout /A or /P, interactive using TCEDIT.EXE
echo ^tDo not quote string
echo ^tString can be of the form dir1;dir2[...]
goto done
:done
endlocal path
set PATH=C:\New\Directory\Here;%PATH%
set PATH=%PATH%;C:\New\Directory\Here