Is there a way to open a link in Lua

319 views
Skip to first unread message

Simply Notes Simply Notes

unread,
Mar 11, 2020, 3:22:15 PM3/11/20
to Notecase Pro
Hi All,

is there a way to open a link, e.g. a link to another node, in Lua?

What I am working on is a way to link to nodes in another document / cross document links. The idea is to store a combination of GlobalDocID and Node ID and when clicked a script gets executed to check whether the linked document is open or open it if necessary and then select the referenced node by its ID

thanks
Raimund

Simply Notes Simply Notes

unread,
Mar 11, 2020, 3:38:45 PM3/11/20
to Notecase Pro
Just found out that using a link to a file is the way forward. I can simply add #{noteID} and when double clicked the document will open with the node specified by the ID.

this way I can create links to external docs without the need to have a lua script to open a link

cheers
Raimund

Paul Merrell

unread,
Mar 11, 2020, 3:46:07 PM3/11/20
to Notecase Pro
Hi, Raimund,

The attached script is as close to what you want to do that I've got
implemented. You might also take look at script links, a link type
found on the Link Manager dialog. From the Help file:

You may choose the "Script link" link type and use that to link to

- an embedded Lua script in the same file
- an embedded Lua script in another NoteCase Pro document file
- a Lua script in a plain text file with a .lua extension

When the user doubleclicks such a link, the linked script is executed.

A Lua script file (this is a very special purpose kind of link: When
double-clicking such a link, the linked Lua script file is executed.
This makes it possible to launch some NoteCase Pro automation from
within the document content by double-clicking a script link)

I need to improve the documentation of that feature. I don't even know
what a script link looks like at the markup level. That should be
documented for scripters.

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.]
¯\_(ツ)_/¯
Tmp.ncz

Paul Merrell

unread,
Mar 11, 2020, 4:07:58 PM3/11/20
to Notecase Pro
On Wed, Mar 11, 2020 at 12:45 PM Paul Merrell <mar...@gmail.com> wrote:
>
> I need to improve the documentation of that feature. I don't even know
> what a script link looks like at the markup level. That should be
> documented for scripters.

Did some experimenting. Here's what the markup looks like on a script link:

<A href="lua:///home/pops/notecase/scripts/CornucopiaScripts.ncz#3KEHNrRdMB1pi3ElMuDRsQ">Test
Lua Link</A>

Paul Merrell

unread,
Mar 11, 2020, 4:22:59 PM3/11/20
to Notecase Pro
On Wed, Mar 11, 2020 at 1:07 PM Paul Merrell <mar...@gmail.com> wrote:
> Did some experimenting. Here's what the markup looks like on a script link:
>
> <A href="lua:///home/pops/notecase/scripts/CornucopiaScripts.ncz#3KEHNrRdMB1pi3ElMuDRsQ">Test
> Lua Link</A>

But when I activate the link from an .ncz file, I get an error
message: "This feature only works for .ncdb/.ncde file formats!"

Reported as probable bug.

Simply Notes Simply Notes

unread,
Mar 12, 2020, 4:03:07 PM3/12/20
to Notecase Pro
Hi Paul,

thanks for your investigations. I was thinking about using a Lua link to open a specified node in an external file. I found out that one can select a NCP file in the link properties dialog and select a node as target for the link. This said the link works only 1 time and then the NoteId seems to get removed from the link. I checked this by opening the link property dialog again. BUT if you select to copy the link target and look at the copied test the NoteID is still part of the link so I think this is a bit buggy ;-)

That's I was considerung a Lua script as link target which then can read a custom property and open the NCP document and select the specified  node

I continue to play aroundwith this concept this

Cheers
Raimund

P.S. I am working on a documentation how I use NCP as this turned into a very powerful CRM kind of solution for me. I love it - Thanks Miro and Paul :-) I also looked at Trilium and I have been playing around with MindRaider but, also they have some fancy features, I love the clean structure and the power of using LUA in NCP

Paul Merrell

unread,
Mar 12, 2020, 4:56:33 PM3/12/20
to Notecase Pro
On Thu, Mar 12, 2020 at 1:03 PM 'Simply Notes Simply Notes' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
> Hi Paul,
>
> thanks for your investigations. I was thinking about using a Lua link to open a specified node in an external file. I found out that one can select a NCP file in the link properties dialog and select a node as target for the link. This said the link works only 1 time and then the NoteId seems to get removed from the link. I checked this by opening the link property dialog again. BUT if you select to copy the link target and look at the copied test the NoteID is still part of the link so I think this is a bit buggy ;-)

Thanks. I reported this as a possible bug.

> P.S. I am working on a documentation how I use NCP as this turned into a very powerful CRM kind of solution for me. I love it - Thanks Miro and Paul :-) I also looked at Trilium and I have been playing around with MindRaider but, also they have some fancy features, I love the clean structure and the power of using LUA in NCP

Love to see your documentation.

Paul Merrell

unread,
Mar 12, 2020, 5:01:20 PM3/12/20
to Notecase Pro
Update on the bug I reported with a script link producing an error
message. It's now not clear whether the bug is with NC Pro or my
script the script link was activating. The script was the one I posted
a few days ago that compacts all open documents that are in database
format.

A bit more experimenting and I was able to reproduce the behavior just
by directly executing the script when the current document is an .ncz.
I await Miro's thinking on whether this is a bug in the script or NC
Pro. I'm not seeing anything in the script that should produce the
error.

Miroslav Rajcic

unread,
Mar 13, 2020, 1:09:04 AM3/13/20
to Notecase Pro
Hi Paul,

the link type you mention below is the link to a lua note (within the external document) to be executed.
If the Raimund does not want to execute lua script, but just link to a document to be opened, the link should use "file://" prefix instead of "lua://".

Regards,
  Miro


From: noteca...@googlegroups.com <noteca...@googlegroups.com> on behalf of Paul Merrell <mar...@gmail.com>
Sent: Wednesday, March 11, 2020 9:07 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/CAJ1g4g_4-%3Dy3AFXoLDiiDEUwGXSLWVgER19Safm0b5-i4bdr%2BA%40mail.gmail.com.

Miroslav Rajcic

unread,
Mar 13, 2020, 1:11:26 AM3/13/20
to Notecase Pro
Feedback: your report was related about completely different API call that turned out to be an issue in the script.

Regards,
  Miro


Sent: Wednesday, March 11, 2020 9:22 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.

Miroslav Rajcic

unread,
Mar 13, 2020, 1:12:35 AM3/13/20
to Notecase Pro
Is this a "lua" type of link or a "file" link?

Regards,
  Miro


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Thursday, March 12, 2020 9:03 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.

Miroslav Rajcic

unread,
Mar 13, 2020, 1:42:29 AM3/13/20
to Notecase Pro
I can confirm the hyperlink bug, will work on it in this cycle.

Regards,
  Miro


Sent: Thursday, March 12, 2020 9:56 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.

Simply Notes Simply Notes

unread,
Mar 13, 2020, 10:41:48 AM3/13/20
to Notecase Pro
Hi Miro,

the objective was to create a link to a node in a different document.
Approach 1 was to use builtin link features and create a link with the node id appended to the filename which works only once and that seems to be the bug this would be a link like file://myextdocu.ncp#xxxxxxxx
Approach 2 was to execute a lua script and read a custom property which has the file and the node informaton. this would be a lua:// link. However this doesn't work because one can't find out which link actually got clicked. So if I have more than one external links in a note I can create the custom property indicating which note I link to but the executed lua script doesn't know whether I clicked on the first, 2nd, 3rd... link

Hope this clarifies things.

best regards
Raimund

Am Freitag, 13. März 2020 06:09:04 UTC+1 schrieb Miro:
Hi Paul,

the link type you mention below is the link to a lua note (within the external document) to be executed.
If the Raimund does not want to execute lua script, but just link to a document to be opened, the link should use "file://" prefix instead of "lua://".

Regards,
  Miro


From: noteca...@googlegroups.com <noteca...@googlegroups.com> on behalf of Paul Merrell <mar...@gmail.com>
Sent: Wednesday, March 11, 2020 9:07 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 
On Wed, Mar 11, 2020 at 12:45 PM Paul Merrell <mar...@gmail.com> wrote:
>
> I need to improve the documentation of that feature. I don't even know
> what a script link looks like at the markup level. That should be
> documented for scripters.

Did some experimenting. Here's what the markup looks like on a script link:

<A href="lua:///home/pops/notecase/scripts/CornucopiaScripts.ncz#3KEHNrRdMB1pi3ElMuDRsQ">Test
Lua Link</A>

--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noteca...@googlegroups.com.

Miroslav Rajcic

unread,
Mar 14, 2020, 2:19:33 AM3/14/20
to Notecase Pro
Thanks Raimund,

as I see it:
  • the solution you need is a file://...#ID  link to the note within the external document
  • creating such link through GUI (Link Properties window) works OK, created link works correctly
  • the bug is if you open the Link Properties window again for the same link and exit window with OK, the #ID part of the link is lost
I am working to fix the bug, but as I see it, you can already use the link, provided you don't return back to edit it once it was created.

Regards,
  Miro


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Friday, March 13, 2020 3:41 PM
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/726867cc-d722-4aea-b08f-2f26c9535197%40googlegroups.com.

Simply Notes Simply Notes

unread,
Mar 14, 2020, 11:13:10 AM3/14/20
to Notecase Pro
Hi Miro,

when you look into the bug please extend it to a related one

I am creating an external link with the attached script letting the user pick one of the open docs and then the node from the selected node.

The bug I think I found is as follows
  1. if the user changes to the document the external link points to and select any other node
  2. then go back to the document with the external link and click the link
  3. NCP jumps to the document the external link points to but doesn't select the node the link points. The selected node from 1. remain the selected on
If the target document is not open and NCP needs to load it than the external link works as expected.

regards
Raimund

P.S: the script is work in progress...
ExtLink.lua

Simply Notes Simply Notes

unread,
Mar 14, 2020, 11:20:14 AM3/14/20
to Notecase Pro
 Sorry I just realized that the script requires a roune from a library so please ignore the lua file. you may used the attached NCP document if you want to test the create external link script

best
Raimund
ExtLink.ncdb

Miroslav Rajcic

unread,
Mar 16, 2020, 12:28:41 AM3/16/20
to Notecase Pro
Thanks, will test.


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Saturday, March 14, 2020 4:20 PM

To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: Is there a way to open a link in Lua
 Sorry I just realized that the script requires a roune from a library so please ignore the lua file. you may used the attached NCP document if you want to test the create external link script

best
Raimund

--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/06c1c16c-8082-4db1-9469-6385322b6f87%40googlegroups.com.

Paul Merrell

unread,
Mar 16, 2020, 1:27:59 AM3/16/20
to Notecase Pro
On Sat, Mar 14, 2020 at 8:20 AM 'Simply Notes Simply Notes' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
> Sorry I just realized that the script requires a roune from a library so please ignore the lua file. you may used the attached NCP document if you want to test the create external link script

On my Linux Mint system, launching ExtLink.ncdb from a file manager results in:

First time -- a program request to compact the document;

Second time -- a program crash.

Miroslav Rajcic

unread,
Mar 29, 2020, 5:06:11 AM3/29/20
to Notecase Pro
Hi Raimund,

can you test a Windows 32-bit version available here:

It should fix the issue with Link Properties window losing the note part of the link target.

Note that only modified files are in archive, so you need to overwrite the same files in the official Windows 32-bit installation.
Also, please use it for testing only, because it may be that some bugs related to new changes are still present.

I am interested in any feedback.

Regards,
  Miro


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Saturday, March 14, 2020 4:13 PM
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/49b50f2c-bdd5-4cd3-b5bb-701506c986a4%40googlegroups.com.

Simply Notes Simply Notes

unread,
Mar 29, 2020, 8:08:05 AM3/29/20
to noteca...@googlegroups.com
Hi Miro

Will test later today or latest tomorrow 

Stay tuned and healthy 

Raimund

Simply Notes Simply Notes

unread,
Mar 30, 2020, 8:34:13 AM3/30/20
to Notecase Pro
Hi Miro,

I tested 4.5.2pre4 and yes the bug that the Link Properties window losing the note part of the link target is fixed! I tested it with manually created links as well as with my script.

The second bug related to this subject is still in the code. When the target document is open the linked note doesn't get selected. If the document is NOT open than the link works as expected

I will also send you a log from a crash. When using my standard notecase-pro.ini file the 4.5.2 pre4 version crashes

best regards

Raimund
Hi Raimund,
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro+unsubscribe@googlegroups.com.

Paul Merrell

unread,
Mar 30, 2020, 4:44:20 PM3/30/20
to Notecase Pro
On Mon, Mar 30, 2020 at 5:34 AM 'Simply Notes Simply Notes' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
I tested it with manually created links as well as with my script.
>

If you're not using it, you'll probably find Daniel's Edit Note HTML
script highly useful. (I keep it assigned to a toolbar icon.) My
edited version, which adds documentation, is attached to this email.

Here is the documentation:

PURPOSE: Edit a note's raw HTML within NoteCase Pro, without need for
an external editor or other external tools. Useful for correcting
invalid markup and when writing a script, to obtain a string's raw,
unescaped HTML for assignment to a variable.

USAGE INSTRUCTIONS:

1. Select the note whose source HTML you want to view or edit, then
then execute this script. A child note with the HTML will be generated
and selected, which you can edit.

2. Once editing is finished, leave the temporary HTML note selected
and then execute this script again. The edited HTML will be put back
into the source note and the temporary HTML note will be deleted.

CONFIGURATION: This script is most useful when assigned to a keyboard
shortcut or a toolbar icon. For instructions, see NoteCase Pro Help
file at Automation, Scripts and Plugins > Launch Scripts and Plugin
Actions Quicker.
Tmp.ncz

Miroslav Rajcic

unread,
Mar 31, 2020, 10:03:10 AM3/31/20
to Notecase Pro
Thanks, will check the remaining issue(s).

Regards,
   Miro


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Monday, March 30, 2020 2:34 PM
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/96591108-ea48-4e7f-97a1-861ec27990e8%40googlegroups.com.

Miro

unread,
Apr 4, 2020, 1:14:37 AM4/4/20
to Notecase Pro
Hi,

the new build should fix the issue with selecting the note in an already loaded document:

Let me know how it works for you.

Regards,
  Miro

Simply Notes Simply Notes

unread,
Apr 4, 2020, 2:19:22 PM4/4/20
to Notecase Pro
Hi Miro,

works perfectly!!!

Great staff

have a great weekend and stay save

Raimund
Hi Raimund,
To unsubscribe from this group and stop receiving emails from it, send an email to notec...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notec...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noteca...@googlegroups.com.

Miroslav Rajcic

unread,
Apr 5, 2020, 1:02:24 AM4/5/20
to Notecase Pro
Thanks Raimund.

Regards,
  Miro


From: 'Simply Notes Simply Notes' via Notecase Pro <noteca...@googlegroups.com>
Sent: Saturday, April 4, 2020 8:19 PM
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/ad81c22f-9023-4bc5-9112-1d4371896e62%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages