Community
    • Login

    How to install and run a script in Python Script?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    24 Posts 3 Posters 7.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterJonesP
      PeterJones @dr ramaanand
      last edited by PeterJones

      @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 FAQ

      It 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 the editor.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 on

      Your 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.

      dr ramaanandD 1 Reply Last reply Reply Quote 1
      • dr ramaanandD
        dr ramaanand @PeterJones
        last edited by dr ramaanand

        @PeterJones I couldn’t do it on that system, so I tried doing it from my other laptop, but I am getting this error:-
        Screenshot (9).png
        This is the DeBug Info of the other laptop which I’m trying to use now:-
        DeBugInfo.png

        PeterJonesP 1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @dr ramaanand
          last edited by

          @dr-ramaanand ,

          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.

          dr ramaanandD PeterJonesP 2 Replies Last reply Reply Quote 0
          • dr ramaanandD
            dr ramaanand @PeterJones
            last edited by dr ramaanand

            @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

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @dr ramaanand
              last edited by

              @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.

              5f0add02-26f0-478b-8c3b-903716ab3bf0-image.png

              That superscript ¹ is a clickable footnote. And if you follow that click, it goes to
              61a9cc43-a617-4d87-a7a6-cb8d22558eae-image.png

              I circled the relevant section for you. I hope this helps.

              dr ramaanandD 1 Reply Last reply Reply Quote 0
              • dr ramaanandD
                dr ramaanand @PeterJones
                last edited by dr ramaanand

                @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?

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @dr ramaanand
                  last edited by

                  @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.

                  dr ramaanandD 1 Reply Last reply Reply Quote 0
                  • dr ramaanandD
                    dr ramaanand @PeterJones
                    last edited by dr ramaanand

                    @PeterJones I did that and got this result:-
                    RenumberingStartingWith1.png
                    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

                    1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @PeterJones
                      last edited by PeterJones

                      @dr-ramaanand ,

                      Hopefully someone else will be able to help you. I’ve spent as much time on this as I can. Again, good luck.

                      dr ramaanandD 1 Reply Last reply Reply Quote 1
                      • dr ramaanandD
                        dr ramaanand @PeterJones
                        last edited by dr ramaanand

                        @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”

                        1 Reply Last reply Reply Quote 0
                        • dr ramaanandD dr ramaanand referenced this topic on
                        • dr ramaanandD dr ramaanand referenced this topic on
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors