Local active Variables
-
When Creating a new Run Command I want to do something like this:
cmd /k && cd &CurrentActiveFilePath && C:\GCC\bin\g++.exe -o &ActiveFilenameWithoutExtension.exe >>&ActiveFilenameWithoutExtension.log
This will invoke the compiler create the executable with the same name as the active file and also create a log file. I need access to the parameters &CurrentActiveFilePath and &ActiveFilenameWithoutExtension . in the run command popup. This run comand can be saved and executed against any file open and compile it provided i have the g++ compiler installed.
Can anybody help with this?
-
The manual contains them, search for FULL_CURRENT_PATH, for example.
-
@Alan-Wynne, besides what @Ekopalypse wrote I believe it would simplify things for you set up a
run-g++.bat
file that will deal with the details. It turns out to be surprisingly hard to run multiple commands usingcmd /K
from Notepad++ as you are dealing with parsing rules set up by Notepad++'s Run/Run thing plus the command processors rules for thecmd /K
thing. UsingC:\GCC\bin\run-g++.bat "$(FULL_CURRENT_PATH)"
from Notepad++'s Run / Run menu will let your batch file take over the work of parsing the full file path to the file being edited in Notepad++ into a directory, the file name part, etc.C:\GCC\bin\run-g++.bat
can be as elaborate as needed and will be easy to maintain and debug. You can take advantage of batch file things such as"%~dp1"
to get the drive letter plus path for your file for thecd
command or%~n1
to get the ActiveFilenameWithoutExtension part. -
IMO, compiling like the OP shows is simple enough to do without creating a batch file. If it gets any more complicated, though, you are definitely right and a batch approach is the way to go.
-
thanks for the input, i have foun a way to do what i need, using npp exec plugin… Create a script:
npp_save
cd "$(CURRENT_DIRECTORY)
del “.\g++.$(NAME_PART).exe”
C:\GCC\bin\g++.exe -g -o “g++.$(NAME_PART).exe” “$(FULL_CURRENT_PATH)”
“.\g++.$(NAME_PART).exe”it does require npp to be running with admin priviladges though…
Thanks for the input…
-
@Alan-Wynne said in Local active Variables:
it does require npp to be running with admin priviladges though…
I use NppExec daily to do similar tasks (in fact, many of the posts that mention
gcc
andNppExec
in the same post in this Forum are my equivalent of the script you just posted), but I have never had to have Admin privileges to save or run an NppExec script.(Though, admittedly, you might need admin privileges to install the plugin – but once you’ve installed it, you can restart Notepad++ without privileges, and the plugin works.)
But under normal usage, what you described should not require admin privileges. Possible exceptions I can think of include: 1) if the file you are compiling is protected, or (2) the directory it’s in is protected; or, (3) if it was because it wouldn’t let you save the NppExec script, then your
%AppData%\Notepad++\Plugins\config\npes_saved.txt
might have weird permissions.