[FORK] Tangential Discussion about what advice is "on topic"
-
Please DO NOT post non-Notepad++ solutions here; it’s a violation of the policy of this Community.
In fact, this posting should be taken down, but I won’t insist on that if there is disagreement.
-
@Alan-Kilborn my apologies; I assumed that the Run feature would respect the script’s directory, but that doesn’t seem to be the case. Added a line to account for that.
-
So you think by putting a non-Notepad++ solution into a Run menu entry makes it a Notepad++ solution, on-topic for this forum? I say: Nope.
-
@Alan-Kilborn IMO, this isn’t that different from the posts that assist users with using the Python plugin to run a Python script.
-
IMO, this isn’t that different from the posts that assist users with using the Python plugin to run a Python script.
Most PythonScript solutions still make use of the files that are actively open in Notepad++, so at least making use of the interface for the files. Your batch file above has nothing to do with Notepad++, other than it’s possible to run through the Run menu.
My general rule of thumb for the “hierarchy” of answers:
- If it’s native Notepad++ solution, it’s completely on-topic.
- If Notepad++ doesn’t have it natively, then suggesting a plugin is reasonable. It’s also reasonable if the plugin offers some major advantage over the native N++ solution
- If there isn’t a specific plugin that does it, suggesting a PythonScript solution is reasonable, or if the PythonScript solution has an obvious advantage.
- helping with the PythonScript is reasonable, but getting too far into the “teaching Python” instead of “what are the specifics that are needed to interface the script to N++” is frowned upon
- NppExec solutions fall into this category as well
- Only give a non-N++ solution if none of the above have been presented yet (and thus there’s a strong indication that there isn’t a way)
- if you must give one of these, keep it brief, and if there are questions, direct them to find help outside the
Easy Run menu solutions (ie,
cmd /c "$(FULL_CURRENT_PATH)"
) are reasonable, as they fit somewhere between the category1 and category3 solution – especially if you’re then indicating how to make them easier to run from the Run menu (using shortcuts, etc). As the Run commands get more complicated, or if they require writing and executing a batch solution, then they are straying into the weeds of a category3. And if it’s just a command-line solution which someone has shoe-horned into a Run command as an excuse to make it “on topic”, it is frowned upon.I will generally let a brief #4 (or shoe-horned #3) slide, as long as the topic doesn’t focus on that solution, and the original asker doesn’t harp on that solution to the exclusion of the more native ones. But if it starts taking over, I am more likely to discourage further discussion down that path.
Unfortunately, on this post, the brief excursion turned into a full-born meta-tangent, spending more bandwidth on the meta than on the actual task at hand.
If the OP comes back with questions about the MultiReplace plugin solution or Mail Merge solution, then he can ask questions about those. But if there’s a problem with the command-line/batch solution, since that doesn’t require the N++ interface, I’d prefer that we direct him to search elsewhere if he wants help with looping in batch files, etc.
-
@PeterJones said in Replace A name for 300 others in the list and save.:
Your batch file above has nothing to do with Notepad++, other than it’s possible to run through the Run menu.
In my defense, I did recommend creating the script in NP++ before adding the pieces about running it from within NP++, but I agree that this is still borderline given that I forgot to explicitly mention the Run feature at first. I also half-expected the individual files to be ready for the replacement stage already, but that part was easy to account for if they weren’t.
I’m sure that the other methods work well, but at first glance, the setup work seemed a bit complicated if you didn’t already have those tools in place. So, the batch-based solution seemed to have a distinct ease-of-implementation advantage even before I remembered the RunMe plugin (which is quick to install and use).
-
@mathlete2 said:
IMO, this isn’t that different from the posts that assist users with using the Python plugin to run a Python script.
If the “PythonScript” is merely a Python program, that really could be run outside of Notepad++, then I agree. But most scripts that people share here are tightly bound to the Notepad++ extensions to Python that the PythonScript plugin provides, specifically via the
notepad
andeditor
objects. -
P PeterJones referenced this topic
-
I personally did not mind @mathlete2’s solution. People can learn a little bit about running scripts from Notepad++ such as that
cd %~p0
thing, a little bit about Run/Run and its[Save]
button hidden in plain sight, a little bit about batch file stuff, and a little bit about PowerShell stuff.The bit about Run/Run vs RunMe went over my head and so I’ll stick to thinking about offering a solution where you use Notepad++ in ANSI mode to directly enter the machine code for a mailmerge.exe app…
-
@mkupper
cd %~p0
is a vunerable line of Batch code. An example:C:\&test>type test1.cmd cd %~p0 echo errorlevel: %errorlevel% echo path: "%~p0" echo cd: "%cd%" pause C:\&test>test1.cmd C:\&test>cd \ & test\ 'test\' is not recognized as an internal or external command, operable program or batch file. C:\>echo errorlevel: 9009 errorlevel: 9009 C:\>echo path: "\&test\" path: "\&test\" C:\>echo cd: "C:\" cd: "C:\" C:\>pause Press any key to continue . . .
The
cd
fails, the following code is run and the current directory has changed toC:\
instead ofC:\&test
. Bad syntax mistakes like this can cause harm depending on the following code. There is no knowing what other users with the characters they may use as path names.cd %~p0 || exit /b 1
is still bad syntax though at least it may exit on error to avoid any further harm. Paths should be quoted in Batch to avoid issues with paths with special characters socd "%~p0" || exit /b 1
is safer. -
I am not sure which amazes me more – that MS didn’t put
&
in the list of disallowed path name characters, despite the fact that it is absolutely a special character in the shell, and most of the the other disallowed characters were there because of the shell-specialness; or that people are still trying to focus on the esoterica of the cmd.exe batch syntax in the thread that enumerates why it’s off topic in this forum. :-) I hope I never get to the point that I’m looking forward to the next big burst of questions questions all about the same thing, like Gaps in the UI border from a few years back, or all the recent DirectWrite-caused issues with the GUI, just so that there’s something for us to focus on that can stay on-topic.