<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Perl subroutine calltips - with PythonScript]]></title><description><![CDATA[<p dir="auto">Taking inspiration from <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> <a href="https://community.notepad-plus-plus.org/topic/16859/microsoft-language-server-protocol-lsp-a-possible-revolution-for-notepad/20">Python “IDE”</a> I’ve been playing with, I tried to use <a href="http://npppythonscript.sourceforge.net/" rel="nofollow ugc">PythonScript</a> to create a Perl subroutine calltip provider for the current Perl script.  It “works”:</p>
<p dir="auto"><img src="/assets/uploads/files/1605795312151-11f4dde4-5155-4d7f-bd08-4c0d94d953bf-image.png" alt="11f4dde4-5155-4d7f-bd08-4c0d94d953bf-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Typing the <code>(</code> open parenthesis triggers the lookup and as you can see in the example, the function “signature” is displayed in the calltip.</p>
<p dir="auto">In case you’re interested, I have “perl_ide.py” in my <code>$(NPP_DIR)/plugins/PythonScript/scripts</code> directory and load it in my “<a href="http://startup.py" rel="nofollow ugc">startup.py</a>” script in the same directory with:</p>
<pre><code>from perl_ide import PerlIDE
__plide = PerlIDE()
__plide.initialize()
</code></pre>
<p dir="auto">And the script itself - feel free to offer improvements - I’m not a Python expert by any means!</p>
<pre><code>''' Basic functionality which one would expect from a full-fledged IDE '''
import re
from Npp import (
    editor, notepad,
    SCINTILLANOTIFICATION, NOTIFICATION, LANGTYPE
    )

class PerlIDE(object):

    def __init__(self):
        self.is_perl = False
        self.excluded_styles = [1, 3, 4, 6, 7, 12, 16, 17, 18, 19]


    def initialize(self):
        editor.callbackSync(self.on_charadded, [SCINTILLANOTIFICATION.CHARADDED])
        notepad.callback(self.on_buffer_activated, [NOTIFICATION.BUFFERACTIVATED])
        self.is_perl = notepad.getCurrentLang() == LANGTYPE.PERL


    def on_buffer_activated(self, args):
        self.is_perl = notepad.getCurrentLang() == LANGTYPE.PERL
        self.path = notepad.getCurrentFilename()


    def on_charadded(self, args):
        if self.is_perl:
            c = chr(args['ch'])
            if c in '\r\n:-+*/#=)':
                return

            pos = editor.getCurrentPos()
            if editor.getStyleAt(pos) in self.excluded_styles:
                return

            if c == '(':
                # subName will contain the subroutine's name from the current typing line 
                # by finding the last open paren `(` and then capturing the word (\w+) 
                # before.  For example:
                #     if ( not defined( $session = getCMSession(
                # should capture `getCMSession`     
                subName = '\0'
                callTip = ""
                line = editor.getCurLine()
                sub = re.search('^.*[\s\t\=](\w+)\s*\(', line)
                if sub:
                    subName = sub.group(1)
                else:
                    return

                # get the entire file into an array, 1 file line per array index
                lines = editor.getText().split("\n")

                # find the start of the sub, form example above, we're looking for 
                # something like:
                #   sub getCMSession {
                start = 0
                for line, text in enumerate(lines):
                    match = re.search(rf"^\s*sub\s+{subName}\s*", text)
                    if match:
                        start = line
                        break
                search = lines[start+1:]

                # new array `search` now starts at the line after the subroutine start
                # we need to find the start of the next sub so we know where to stop 
                # searching.  The next sub starts at a line like:
                #     "sub "
                # without the double-quotes, but the 'sub' must be followed by 
                # some whitespace
                end = 0
                for line, text in enumerate(search):
                    match = re.search('^\s*sub\s+', text)
                    if match:
                        end = line
                        break
                sub = search[0:end]

                # the new array `sub` now contains each line of the full subName 
                # subroutine's code, let's search for a function signature looking thing
                for line, text in enumerate(sub):
                    match = re.search('^\s*my\s+.*\s*\=\s*\@\_\;', text)
                    if match:
                        callTip = match.group(0)
                        editor.callTipShow(pos, callTip)
                        break

</code></pre>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20340/perl-subroutine-calltips-with-pythonscript</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 23:19:31 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20340.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Nov 2020 14:29:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Mon, 23 Nov 2020 13:31:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/60091">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">Just to make clear, this function is not really needed.</p>
</blockquote>
<p dir="auto">That worked!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60092</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60092</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Mon, 23 Nov 2020 13:31:01 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Mon, 23 Nov 2020 12:52:07 GMT]]></title><description><![CDATA[<p dir="auto">Just to make clear, this function is not really needed.<br />
It just provides a textual description of an error number.<br />
One can comment</p>
<pre><code>            # _error = Perl_sv_pv(my_perl, 
            #                    Perl_sv_string_from_errnum(my_perl, res, None))
</code></pre>
<p dir="auto">and change the runtime raise to</p>
<pre><code>raise(RuntimeError(f'Perl interpreter setup error. {res}'))
</code></pre>
<p dir="auto">and it should work. Hopefully.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60091</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60091</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 23 Nov 2020 12:52:07 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Mon, 23 Nov 2020 12:47:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">according to git this api function was introduced in 2017</p>
<pre><code>658db62260a (Zefram                   2017-08-13 01:59:43 +0100  689) #define sv_string_from_errnum(a,b)        Perl_sv_string_from_errnum(aTHX_ a,b)
</code></pre>
<p dir="auto">but 5.24 has been released on May 8, 2016</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60090</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60090</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 23 Nov 2020 12:47:21 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Mon, 23 Nov 2020 12:13:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">Thx for testing. I think I’m using the newer version, mine is called 5.32.<br />
Any thoughts on what a reasonable version to start with might be?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60089</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60089</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 23 Nov 2020 12:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Mon, 23 Nov 2020 01:22:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/60074">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">I’m afraid, it works, currently, only with PythonScript version 3.x</p>
</blockquote>
<p dir="auto">And maybe “newer” Perl as well.  I’m on Strawberry 5.24 and get this:</p>
<pre><code>Traceback (most recent call last):
  File "C:\usr\bin\npp64\plugins\PythonScript\scripts\EmbeddedPerl.py", line 46, in &lt;module&gt;
    Perl_sv_string_from_errnum = perllib.Perl_sv_string_from_errnum
  File "C:\usr\bin\npp64\plugins\PythonScript\lib\ctypes\__init__.py", line 386, in __getattr__
    func = self.__getitem__(name)
  File "C:\usr\bin\npp64\plugins\PythonScript\lib\ctypes\__init__.py", line 391, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Perl_sv_string_from_errnum' not found
</code></pre>
<p dir="auto">I don’t want to sound ungrateful - what you’ve done is amazing, just thought you should know.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60082</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60082</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Mon, 23 Nov 2020 01:22:56 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Sun, 22 Nov 2020 23:29:55 GMT]]></title><description><![CDATA[<p dir="auto">I guess I have a working solution.<br />
I’m afraid, it works, currently, only with PythonScript version 3.x<br />
There is one open point, see TODO, which I can’t seem to find a solution for.</p>
<pre><code class="language-py">from ctypes import CDLL, POINTER, c_int, c_char_p, c_void_p, byref, CFUNCTYPE
from Npp import console

perllib = CDLL(r'D:\strawberry\perl\bin\perl532.dll')

# Perl_sys_init3(int* argc, char*** argv, char*** env)
Perl_sys_init3 = perllib.Perl_sys_init3
Perl_sys_init3.argtypes = [POINTER(c_int), POINTER(POINTER(c_char_p)), POINTER(POINTER(c_char_p))]

# PerlInterpreter * perl_alloc(void)
perl_alloc = perllib.perl_alloc
perl_alloc.restype = c_void_p
perl_alloc.argtypes = []

# void perl_construct(pTHXx)
perl_construct = perllib.perl_construct
perl_construct.argtypes = [c_void_p]

# int perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)  # only 4 params but pTHXx_ is a macro resulting in 5 params
xsinit = CFUNCTYPE(None, c_void_p)
perl_parse = perllib.perl_parse
perl_parse.restype = c_int
perl_parse.argtypes = [c_void_p, xsinit, c_int, POINTER(c_char_p), POINTER(c_char_p)]

# int perl_run(pTHXx)
perl_run = perllib.perl_run
perl_run.restype = c_int
perl_run.argtypes = [c_void_p]

# int perl_destruct(pTHXx)
perl_destruct = perllib.perl_destruct
perl_destruct.restype = c_int
perl_destruct.argtypes = [c_void_p]

# SV* Perl_eval_pv(pTHX_ const char *p, I32 croak_on_error)
Perl_eval_pv = perllib.Perl_eval_pv
Perl_eval_pv.restype = c_void_p
Perl_eval_pv.argtypes = [c_void_p, c_char_p, c_int]

# SV * Perl_sv_pv(pTHX_ const IV i)
Perl_sv_pv = perllib.Perl_sv_pv
Perl_sv_pv.restype = c_char_p
Perl_sv_pv.argtypes = [c_void_p, c_void_p]

# SV * Perl_sv_string_from_errnum(pTHX_ int errnum, SV *tgtsv)
Perl_sv_string_from_errnum = perllib.Perl_sv_string_from_errnum
Perl_sv_string_from_errnum.restype = c_void_p
Perl_sv_string_from_errnum.argtypes = [c_void_p, c_int, c_void_p]

# SV* Perl_get_sv(pTHX_ const char *name, I32 flags)
Perl_get_sv = perllib.Perl_get_sv
Perl_get_sv.restype = c_void_p
Perl_get_sv.argtypes = [c_void_p, c_char_p, c_int]

# void boot_DynaLoader (pTHX_ CV* cv)
boot_DynaLoader = perllib.boot_DynaLoader
boot_DynaLoader.argtypes = [c_void_p, c_char_p]

# Perl_newXS(pTHX_ const char *name, XSUBADDR_t subaddr, const char *filename)
Perl_newXS = perllib.Perl_newXS
Perl_newXS.argtypes = [c_void_p, c_char_p, c_void_p, c_char_p]


class PerlInterpreter:

    def __init__(self):
        Perl_sys_init3(byref(c_int(3)), None, None)


    @staticmethod
    def call(perlcode):
        # TODO: https://perldoc.perl.org/perlembed#Maintaining-a-persistent-interpreter
        # PL_exit_flags |= 0x2  # PERL_EXIT_DESTRUCT_END 
        # I assume, that this would avoid calling alloc, construct and parse over and over again.
        # but how can we set it, seems not to be exported.
        # Following code fails: ValueError: symbol 'PL_exit_flags' not found

        # exit_flags = c_int.in_dll(perllib, 'PL_exit_flags')
        # exit_flags.value |= 2
        
        my_perl = perl_alloc()
        perl_construct(my_perl)
        
        def xs_init(pTHX):
            # https://perldoc.perl.org/perlembed#Using-Perl-modules,-which-themselves-use-C-libraries,-from-your-C-program
            Perl_newXS(pTHX, 
                       b"DynaLoader::boot_DynaLoader", 
                       boot_DynaLoader, 
                       b'__FILE__' # Seems to work, but ... ??
                       )

        res = perl_parse(my_perl, xsinit(xs_init), 3, (c_char_p * 3)(*[b"", b"-e", b"0"]), None)
        if res != 0:
            _error = Perl_sv_pv(my_perl, 
                                Perl_sv_string_from_errnum(my_perl, res, None))

            perl_destruct(my_perl)
            raise(RuntimeError(f'Perl interpreter setup error. {_error.decode()}'))

        result = Perl_sv_pv(my_perl, 
                            Perl_eval_pv(my_perl, c_char_p(perlcode.encode()), 0))
        
        error = Perl_sv_pv(my_perl, Perl_get_sv(my_perl, "@".encode(), 0)).decode()

        perl_destruct(my_perl)
        return error, result.decode()


if __name__ == '__main__':
    perl = PerlInterpreter()
    for perlcode in [
                     "use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();",
                     "reverse 'rekcaH lreP rehtonA tsuJ'", 
                     "$a = 3; $a **= 2",
                     "$a = 3; $a **= ",
                     ]:
        error, result = perl.call(perlcode)
        if error:
            console.writeError(error+'\n')
        else:
            print(result)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/60074</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60074</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Sun, 22 Nov 2020 23:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 22:19:05 GMT]]></title><description><![CDATA[<p dir="auto">I guess I have a working “embedded” perl instance.</p>
<pre><code class="language-py">
from ctypes import CDLL, POINTER, c_int, c_char_p, c_void_p, byref

perllib = CDLL(r'D:\strawberry\perl\bin\perl532.dll')

# Perl_sys_init3(int* argc, char*** argv, char*** env)
perllib.Perl_sys_init3.argtypes = [POINTER(c_int), POINTER(POINTER(c_char_p)), POINTER(POINTER(c_char_p))]

# PerlInterpreter * perl_alloc(void)
perllib.perl_alloc.restype = c_void_p
perllib.perl_alloc.argtypes = []

# void perl_construct(pTHXx)
perllib.perl_construct.argtypes = [c_void_p]

# int perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)  # only 4 params ??
perllib.perl_parse.restype = c_int
perllib.perl_parse.argtypes = [c_void_p, c_void_p, c_int, POINTER(c_char_p), POINTER(c_char_p)]  # we need 5 params according to RunPerl

# int perl_run(pTHXx)
perllib.perl_run.restype = c_int
perllib.perl_run.argtypes = [c_void_p]

# int perl_destruct(pTHXx)
perllib.perl_destruct.restype = c_int
perllib.perl_destruct.argtypes = [c_void_p]

# SV* Perl_eval_pv(pTHX_ const char *p, I32 croak_on_error)
perllib.Perl_eval_pv.restype = c_void_p
perllib.Perl_eval_pv.argtypes = [c_void_p, c_char_p, c_int]

# # SV * Perl_sv_pv(pTHX_ const IV i)
perllib.Perl_sv_pv.restype = c_char_p
perllib.Perl_sv_pv.argtypes = [c_void_p, c_void_p]


__args = [b"", b"-e", b"0"]  # test_npp
args = (c_char_p * len(__args))(*__args)

perllib.Perl_sys_init3(byref(c_int(len(args))), None, None)
my_perl = perllib.perl_alloc()
perllib.perl_construct(my_perl)
if perllib.perl_parse(my_perl, None, len(args), args, None) == 0:
    for perlcode in [b"reverse 'rekcaH lreP rehtonA tsuJ'", b"$a = 3; $a **= 2", b"$a = 3; $a **= "]:
        val = perllib.Perl_eval_pv(my_perl, c_char_p(perlcode), 0)
        print(perllib.Perl_sv_pv(my_perl, val))
else:
    print('Perl interpreter setup error.')

print(perllib.perl_destruct(my_perl))
</code></pre>
<p dir="auto">Next step would be to identify errors (see last example code)<br />
and make additional modules working. I assume this has something<br />
to do with the @INC …<br />
and of course make a class out of it for easy reuse.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60007</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60007</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 20 Nov 2020 22:19:05 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 16:57:09 GMT]]></title><description><![CDATA[<p dir="auto">Hmm … it looks like freeing the interpreter is the issue.<br />
I tried to replicate what RunPerl is doing and when I use this</p>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p, c_void_p, byref

perllib = CDLL(r'D:\strawberry\perl\bin\perl532.dll')

# perllib.RunPerl.restype = c_int
# perllib.RunPerl.argtypes = [c_int, POINTER(c_char_p), POINTER(c_char_p)]

# Perl_sys_init3(int* argc, char*** argv, char*** env)
perllib.Perl_sys_init3.argtypes = [POINTER(c_int), POINTER(POINTER(c_char_p)), POINTER(POINTER(c_char_p))]

# PerlInterpreter * perl_alloc(void)
perllib.perl_alloc.restype = c_void_p
perllib.perl_alloc.argtypes = []

# void perl_construct(pTHXx)
perllib.perl_construct.argtypes = [c_void_p]

# int perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)  # only 4 params ??
perllib.perl_parse.restype = c_int
perllib.perl_parse.argtypes = [c_void_p, c_void_p, c_int, POINTER(c_char_p), POINTER(c_char_p)]  # we need 5 params according to RunPerl

# int perl_run(pTHXx)
perllib.perl_run.restype = c_int
perllib.perl_run.argtypes = [c_void_p]

__args = [b"", b"D:\\scripts\\perl\\1.pl" ]
# ********************************  content of 1.pl  ********************************
# use strict;
# use warnings;

# my $timestamp = localtime(time);

# sub logit {
	# my $message = shift;
	# my $filename = 'D:/report.txt';
	# open(my $fh, '&gt;&gt;', $filename) or die "Could not open file '$filename' $!";
	# print $fh $timestamp, " $message\n";
	# close $fh;
# }

# logit("test");
# **********************************************************************************


args = (c_char_p * len(__args))(*__args)

perllib.Perl_sys_init3(byref(c_int(len(args))), None, None)
my_perl = perllib.perl_alloc()
perllib.perl_construct(my_perl)
result = perllib.perl_parse(my_perl, None, len(args), args, None)
print('perl_parse', result)
result = perllib.perl_run(my_perl)
print('perl_run', result)
print(open(r'D:\report.txt', 'r').read())

</code></pre>
<p dir="auto">I can run <a href="http://1.pl" rel="nofollow ugc">1.pl</a> multiple times</p>
<p dir="auto"><img src="/assets/uploads/files/1605891420209-6adc4473-18cb-43e8-acb2-48c5cb32b519-image.png" alt="6adc4473-18cb-43e8-acb2-48c5cb32b519-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/59984</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59984</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 20 Nov 2020 16:57:09 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 14:42:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/59954">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">I wonder why it needs the blank argument…</p>
</blockquote>
<p dir="auto">I read some stuff on <a href="https://metacpan.org/pod/PAR::Packer" rel="nofollow ugc">Par::Packer</a> and it seems the first argument may be the optional path to the <code>perl</code> executable.</p>
<p dir="auto"><a href="https://oliverbetz.de/pages/Artikel/Portable-Perl-Applications" rel="nofollow ugc">https://oliverbetz.de/pages/Artikel/Portable-Perl-Applications</a></p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59956</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59956</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Fri, 20 Nov 2020 14:42:57 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 14:36:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/59946">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto"><code>__args = [b"",</code> …</p>
</blockquote>
<p dir="auto">Weird.  If I don’t have the empty zeroth argument, the call fails (x==9).  I wonder why it needs the blank argument…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59954</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59954</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 20 Nov 2020 14:36:13 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 14:29:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/59946">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">Seems some cleanup needs to be done afterwards.</p>
</blockquote>
<p dir="auto">Yes, in my late night Google-ing I saw lots of references to <code>free(args)</code> after the <code>RunPerl()</code> call.</p>
<p dir="auto">Examples:<br />
<a href="https://comp.lang.perl.misc.narkive.com/r7M6eENL/dll-unload-question-for-embedded-perl-on-windows" rel="nofollow ugc">https://comp.lang.perl.misc.narkive.com/r7M6eENL/dll-unload-question-for-embedded-perl-on-windows</a><br />
<a href="https://www.nntp.perl.org/group/perl.wxperl.users/2017/01/msg9715.html" rel="nofollow ugc">https://www.nntp.perl.org/group/perl.wxperl.users/2017/01/msg9715.html</a></p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59952</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59952</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Fri, 20 Nov 2020 14:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 13:50:28 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I should have installed strawberry perl in first place, solved all my issues.</p>
<p dir="auto">First success</p>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p

perllib = CDLL(r'D:\strawberry\perl\bin\perl532.dll')

perllib.RunPerl.restype = c_int
perllib.RunPerl.argtypes = c_int, POINTER(c_char_p), POINTER(c_char_p)

__args = [b"",
          b"-le",
          b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"]
          
args = (c_char_p * len(__args))(*__args)
x = perllib.RunPerl(len(args), args, None)
print(x)
</code></pre>
<p dir="auto">This works, but only one time. A second call results in a<br />
<code>OSError: exception: access violation writing 0x0000000000000024</code></p>
<p dir="auto">Seems some cleanup needs to be done afterwards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59946</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59946</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 20 Nov 2020 13:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Fri, 20 Nov 2020 00:18:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a></p>
<p dir="auto">Same 9.</p>
<p dir="auto">I tried both:</p>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p

perllib = CDLL(r'C:\Strawberry\perl\bin\perl524.dll')

["-e", "use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"]

perllib.RunPerl.restype = c_int
perllib.RunPerl.argtypes = c_int, POINTER(c_char_p), POINTER(c_char_p)
args = (c_char_p * 2)(b"-e", b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();")
print(perllib.RunPerl(len(args),args,(c_char_p * 1)(b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();")))
</code></pre>
<p dir="auto">and</p>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p

perllib = CDLL(r'C:\Strawberry\perl\bin\perl524.dll')

["-e", "use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"]

perllib.RunPerl.restype = c_int
perllib.RunPerl.argtypes = c_int, POINTER(c_char_p), POINTER(c_char_p)
args = (c_char_p * 2)(b"-e", b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();")
print(perllib.RunPerl(len(args),args,(c_char_p * 1)(b'')))
</code></pre>
<p dir="auto"><em><strong>HOWEVER</strong></em> … this:</p>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p

perllib = CDLL(r'C:\Strawberry\perl\bin\perl524.dll')

["use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"]

perllib.RunPerl.restype = c_int
perllib.RunPerl.argtypes = c_int, POINTER(c_char_p), POINTER(c_char_p)
args = (c_char_p * 1)(b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();")
print(perllib.RunPerl(len(args),args,None))
</code></pre>
<p dir="auto">produces <code>0</code> in the PythonScript console.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59926</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59926</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Fri, 20 Nov 2020 00:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:34:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">Can you try one more thing?<br />
Replace the RunPerl call with this<br />
<code>print(perllib.RunPerl(len(args), args, (c_char_p * 1)(b'')))</code><br />
With the newFile code, please.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59925</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59925</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:25:14 GMT]]></title><description><![CDATA[<p dir="auto">Ja, 42 would be nice :-)<br />
So 9 seems to be an error code.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59924</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59924</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:25:14 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:24:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/59921">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">Can you try</p>
</blockquote>
<pre><code>from ctypes import CDLL, POINTER, c_int, c_char_p

perllib = CDLL(r'C:\Strawberry\perl\bin\perl524.dll')

["-le", "use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"]

perllib.RunPerl.restype = c_int
perllib.RunPerl.argtypes = c_int, POINTER(c_char_p), POINTER(c_char_p)
args = (c_char_p * 2)(b"-le", b"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();")
print(perllib.RunPerl(len(args),args, None))
</code></pre>
<p dir="auto">It just prints <code>9</code> in the PythonScript console. No new tab is opened.  If I run the command itself from a prompt:</p>
<pre><code>C:\ &gt; perl -e "use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"
</code></pre>
<p dir="auto">I get a new tab in Notepad++ as expected.</p>
<p dir="auto">At least if it printed <a href="https://en.wikipedia.org/wiki/42_(number)" rel="nofollow ugc"><code>42</code></a> we’d know we’re on to something …</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59923</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59923</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:24:20 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:16:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">My Win32::API has been built but not installed because of failing tests I guess. Can you try the <code>"use Win32::Mechanize::NotepadPlusPlus qw/:main/; notepad-&gt;newFile();"</code> and see what happens?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59921</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59921</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:14:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/59919">Perl subroutine calltips - with PythonScript</a>:</p>
<blockquote>
<p dir="auto">I get also 9</p>
</blockquote>
<p dir="auto">Oh, OK - great then.  Seems I may be able to keep testing along without having to build a Perl and just use my Strawberry install.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59920</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59920</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:14:56 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:13:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">I get also 9 and from the function it seems correct to return an int.<br />
See my previous post. RunPerl returns only an int. Not sure how to get the result (the print output), so far.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59919</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59919</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:13:58 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:11:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a><br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">Is there a reason you build your own Perl?  I have Strawberry 5.24 installed and doing this works:</p>
<p dir="auto"><img src="/assets/uploads/files/1605827419198-970a1b75-52c3-4044-b6aa-e253bb3e979c-image.png" alt="970a1b75-52c3-4044-b6aa-e253bb3e979c-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">That’s <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> script from above using my “system” Strawberry Perl 5.24 DLL (the Perl that has my Win32::Mechanize::NotepadPlusPlus and all my other stull installed on it).  Not sure why it’s printing “9” in the PythonScript console - is that what it’s supposed to do?  I thought I’d get that string <code>"print something ...</code></p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59918</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59918</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:11:59 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:08:43 GMT]]></title><description><![CDATA[<p dir="auto">finished - but no Win32::API. started cpan Win32::API now.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59917</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59917</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:08:43 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:06:27 GMT]]></title><description><![CDATA[<p dir="auto">it does this now since ~10 minutes</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59916</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59916</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:06:27 GMT</pubDate></item><item><title><![CDATA[Reply to Perl subroutine calltips - with PythonScript on Thu, 19 Nov 2020 23:05:46 GMT]]></title><description><![CDATA[<p dir="auto">I have cpan and it keeps installing stuff - did I choose to install the world??</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59915</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59915</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 19 Nov 2020 23:05:46 GMT</pubDate></item></channel></rss>