Launching a lua script from a 2nd Plugin

23 views
Skip to first unread message

info.sim...@googlemail.com

unread,
Aug 13, 2021, 4:16:03 AM8/13/21
to Notecase Pro

Hello all,

I'd like to be able to launch a script from an installed plugin. Nc_Script_Execute seems the call I need but how can I get the document ID for the installed plugin if the executed script is not contained in the plugin?
Nc_Script_DocID_Get only returns the current document ID.

I tried to get the file path of the installed plugins, and then use Nc_Doc_FindByPath but this returns -1 in any case .

strX = Nc_App_RegisteredPlugin_Name_GetByIdx(j)
Nc_GUI_MessageBox(strX)
Nc_GUI_MessageBox(Nc_App_RegisteredPlugin_Path_GetByIdx(j))
nScriptDocID =
Nc_Doc_FindByPath(Nc_App_RegisteredPlugin_Path_GetByIdx(j))
Nc_GUI_MessageBox(nScriptDocID)

Any ideas by anyone?

Thanks
Raimud

Paul Merrell

unread,
Aug 13, 2021, 8:06:34 AM8/13/21
to Notecase Pro
On Fri, Aug 13, 2021 at 1:16 AM 'info.sim...@googlemail.com' via Notecase Pro <noteca...@googlegroups.com> wrote:

Hello all,

I'd like to be able to launch a script from an installed plugin. Nc_Script_Execute seems the call I need but how can I get the document ID for the installed plugin if the executed script is not contained in the plugin?
Nc_Script_DocID_Get only returns the current document ID.

Hi, Raimud,

Nc_Script_DocID_Get would have to be executed by a script that is in the plugin to get the plugin's DocID (assuming that it is working as documented in the Help file). But it sounds somewhat like you want to call that method from the executed script that is not contained in the plugin.  

If that is correct, then you might instead try modifying the plugin such that when it loads, it gets the plugin DocID using Nc_Script_DocID_Get() and generates an .ini file to store that DocID, that gets the plugin's DocID and stores it in the .ini file, then calls the .ini file from the external script to get the plugin DocID. Under this approach, the plugin would overwrite  the  .ini file anew on each launch of the plugin. 

Daniel's Plugin Developer Tools ("PDT"), when it creates a plugin template, embeds a library called Nc_inilazy_hmc that simplifies working with .ini files. If you open the PDT's Help file, inilazy library usage is documented at Tips and Tricks > Configuration / INI file handling: How to use Nc_inilazy_hmc library

I hope this helps.  
 
Best regards,

Paul


--
[Notice not included in the above original message:  The U.S. National Security Agency neither confirms nor denies that it intercepted this message.]
                                                ¯\_(ツ)_/¯

Virus-free. www.avg.com

info.sim...@googlemail.com

unread,
Aug 13, 2021, 9:18:25 AM8/13/21
to Notecase Pro
Hi Paul,

great idea to solve it! It actually would also be an easy way to find out whether the correct Plugin is loaded. Will give it a try and post progress. Re ini files I have my own routines handy.

best regards

Raimund

info.sim...@googlemail.com

unread,
Aug 14, 2021, 1:30:59 PM8/14/21
to Notecase Pro
Hi Paul,

just an update that your suggestion works just fine. On Initialize in the PlugIn I add the doc ID to the ini file for the Plugin. every script within the Plugin got a custom property (I use "$$ScriptID") which holds a string to identify the note. This way I can rename the note but still identify it - even when the note ID changes.

thanks again for your suggestion!

best regards

Raimund

Paul Merrell

unread,
Aug 14, 2021, 6:41:49 PM8/14/21
to Notecase Pro
On Sat, Aug 14, 2021 at 10:31 AM 'info.sim...@googlemail.com' via Notecase Pro <noteca...@googlegroups.com> wrote:
Hi Paul,

just an update that your suggestion works just fine. On Initialize in the PlugIn I add the doc ID to the ini file for the Plugin. every script within the Plugin got a custom property (I use "$$ScriptID") which holds a string to identify the note. This way I can rename the note but still identify it - even when the note ID changes.

Great! I'm glad it worked for you. 

Best regards,

Paul
 
--
[Notice not included in the above original message:  The U.S. National Security Agency neither confirms nor denies that it intercepted this message.]
                                                ¯\_(ツ)_/¯

Virus-free. www.avg.com
Reply all
Reply to author
Forward
0 new messages