Jump to content

How do you get Python Script working on Notepad++

I have so far (in theory) downloaded python script and installed it and it should be working (Again in theory) the problem is now the macro I am trying to run isn't working and I am not sure if this is because the code is not working or if something else isn't. The console seams to be working and the macro is shown below. All it is to do is turn

1

2

3

4

into

1, 2, 3, 4

and well it's not and I have about 500 sets to do that to so I would like to work at somepoint. Have I just made a stupid mistake or is there some other issue

def Split(Lines):
    Output = ""
    First = True
    C = 0
    Max = len(Lines) - 1
    while (C < Max):
        if (First):
            First = False
            Output = Lines[C]
        else:
            Output = Output + ", " + Lines[C]
        C += 1
    if (not (IsEmpty(Lines[Max]))):
        Output = Output + "," + Lines[Max]
    return Output

def IsEmpty(Line):
    for Char in Line:
        if (Char != " "):
            return False
    return True

Lines = editor.getText().Split("\r\n")
print(Lines)
SplitLines = Split(Lines)
print(SplitLines)
editor.setText(SplitLines)

 

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
Share on other sites

Link to post
Share on other sites

Your problem is with the python code. Nothing to do with Notepad++

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Franck said:

Your problem is with the python code. Nothing to do with Notepad++

what's the issue with my code???

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
Share on other sites

Link to post
Share on other sites

On 5/17/2019 at 2:52 PM, grimreeper132 said:

what's the issue with my code???

editor is not defined when calling editor.getText()

 

Oops. Just noticed the miss-spell. Sorry about that. Corrected. 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Orcblood said:

editor is not defended when calling editor.getText()

Also you know theax number of lines so you should do a for loop

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Lines = editor.getText().Split("\r\n")

Where is editor object? And its method getText? I dont see editor called anywhere in the code before it shows up first time? 

Link to comment
Share on other sites

Link to post
Share on other sites

On 5/20/2019 at 2:34 AM, MladenM said:

Lines = editor.getText().Split("\r\n")

Where is editor object? And its method getText? I dont see editor called anywhere in the code before it shows up first time? 

it is the open document, used to get the text from the open TXT file.

 

 

 

The problem is the plugin manager was not installing it correctly. This is the install instructions I found
https://notepad-plus-plus.org/community/topic/17256/guide-how-to-install-the-pythonscript-plugin-on-notepad-7-6-3-7-6-4-and-above
 

Here's the documentation about the plugin which explains how to code for this plugin

http://npppythonscript.sourceforge.net/docs/latest/index.html

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 weeks later...
On 5/23/2019 at 6:37 PM, grimreeper132 said:

it is the open document, used to get the text from the open TXT file.

 

 

 

The problem is the plugin manager was not installing it correctly. This is the install instructions I found
https://notepad-plus-plus.org/community/topic/17256/guide-how-to-install-the-pythonscript-plugin-on-notepad-7-6-3-7-6-4-and-above
 

Here's the documentation about the plugin which explains how to code for this plugin

http://npppythonscript.sourceforge.net/docs/latest/index.html

Sorry i wasnt looking at forum for a while.

Have you solved it?
 

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/14/2019 at 11:54 PM, MladenM said:

Sorry i wasnt looking at forum for a while.

Have you solved it?
 

yea I think the install was dodgy or something like that

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×