How to install and run a script in Python Script?
-
@dr-ramaanand said in How to install and run a script in Python Script?:
@PeterJones OK, so how do I do Plugins > Python Script > Context-Help, then choose Editor Object, and go to the editor.rereplace() section ?
I still am not sure what you intend by this sentence – that instruction isn’t in the FAQ,
so I’m not sure where you’re getting it (unless it’s from the actual script that you’re trying to install).Update: I did some more searching: that was a line from the mathematical replacement FAQ; the next paragraph below correctly interprets my sentence from that second FAQIt is literally telling you: click the Plugins menu, click PythonScript then click Contenxt-Help, then go click on the Editor Object, then search the page for
editor.rereplace
, and you will find the help so that you can learn more about theeditor.rereplace()
command. Addendum: That was not part of the instructions on how to run it; that was part of the instructions on how to learn more about the commands involved, so that you can learn during the experience, and learn how to customize the example scripts, because we aren’t going to always spoonfeed you.How do I add this script and run it ?:-
I’m trying to replace<sup>[0]</sup>
with<sup>[1]</sup>
and renumber the rest as<sup>[2]</sup>
,<sup>[3]</sup>
,<sup>[4]</sup>
,<sup>[5]</sup>
,<sup>[6]</sup>
,<sup>[7]</sup>
and so onYour script looks like it’s a good starting place, based on the example scripts you copied it from.
Then follow the instructions from the FAQ to create a new script, giving it a meaningful name, paste your script which you just showed into it, save it, and run it. The FAQ gives step-by-step, point-by-point instructions for how to do this, and I cannot say it any better than it’s already described in the FAQ.
----
Please note: This Community Forum is not a data transformation or free-code-writing service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and the problem can be easily solved with a regular expression, we’ll likely give you a start on that. And if it requires scripting (more complex logic than can easily be done in a regular expression), we will let you know. If your problem catches the interest of one of the regulars, that person may even provide an example script that may be helpful; often times, we might even ask you to search the forum for a particular term, because that term will likely help you find a script that already implements something similar. Whether it’s a previously-written script, or whether one of us hacks something up for you specifically, it won’t always exactly match your problem, but it’s at least a starting point for you to work from. At that point, you are expected to take the lead, and make any changes to the example that are necessary to convert it from what was provided to something that meets you exact needs. This forum is focused on Notepad++; while you may want to use Notepad++ for the implementation, text editors aren’t always the right tool for complex text transformation tasks: since you are seeing this boilerplate in my reply, it means that I believe that it’s essentially a generic programming challenge, which is off topic for a Notepad++-specific forum.
-
@PeterJones I couldn’t do it on that system, so I tried doing it from my other laptop, but I am getting this error:-
This is the DeBug Info of the other laptop which I’m trying to use now:-
-
I have no clue how you made it do that – sounds like you’ve done some strange configuration to your Windows 7 setup to get it to give an error like that. Just open
c:\program files\notepad++\plugins\PythonScript\doc\index.html
in your favorite browser and use that for referencing the PythonScript documentation instead of using the menu option.But just so we are clear: Reading the documentation to see the original source of the
add_1
script has nothing to do with running the script. The FAQ: How to Install and Run A Script in PythonScript tells you the step-by-step instructions for how to install and run the script. I think you need to focus on that, before trying to read the documentation and see where the script was derived from.Also, to be clear: if you have more difficulty in trying to follow the instructions and trying to get the script to run, you’ll have to hope that someone else here will be able to reply, because I’ve given you as much information as I can. Good luck.
-
@PeterJones said in How to install and run a script in Python Script?:
FAQ: How to Install and Run A Script in PythonScript
In the above, I think point no.1. Create a new script should mention, “script” directory, not, “user script” directory
-
@dr-ramaanand said in How to install and run a script in Python Script?:
@PeterJones said in How to install and run a script in Python Script?:
FAQ: How to Install and Run A Script in PythonScript
In the above, I think point no.1. Create a new script should mention, “script” directory, not, “user script” directory
It should not. The “user script” directory is well defined in the FAQ.
That superscript ¹ is a clickable footnote. And if you follow that click, it goes to
I circled the relevant section for you. I hope this helps.
-
@PeterJones Yes, that helped. Thanks! I did all that was asked to be done in that FAQ. Now how to Renumber every <sup>followed by a number, starting with 1 in my file?
-
@dr-ramaanand said in How to install and run a script in Python Script?:
I did all that was asked to be done in that FAQ. Now how to Renumber …
The “USAGE” section in the FAQ explains how to run the script.
-
@PeterJones I did that and got this result:-
I think I now got to go and remove the\
before the[
bracket from my file in the user script directory
Is there a way to edit that or should I create a new script?
Of course, the easiest way around this is to find<sup>\
and replace it with<sup>
Unfortunately, I am unable to find<sup>\
in either the Normal mode or the Regular Expression mode -
Hopefully someone else will be able to help you. I’ve spent as much time on this as I can. Again, good luck.
-
@PeterJones OK, thanks a lot! “
<sup>.*?\[
” finds what I want it to find, that is “<sup>\[
” with the Regular expression mode turned on. I then put “<sup>[
” in the Replace with field and hit “Replace all” -
-