question re Nc_Note_CustProp_Append

13 views
Skip to first unread message

info.sim...@googlemail.com

unread,
Sep 14, 2022, 10:51:11 AM9/14/22
to Notecase Pro
according to help and my past coding Nc_Note_CustProp_Append is supposed to append a custom property regardless whether a custom property with the same name exists.
That's why I used a own routine in the past to check whether the custom property exists (by name) and then either set the value (if it exists) or use the append method to add it.

Running NCP 4.6.6 Linux it appears that Nc_Note_CustProp_Append will overwrite an existing custom property if it exists and not duplicate the custom property name.

In my use case it would actually be good if it simply appends a custom property with the same name so I don't have to maintain a counter but can simply cycle through all custom properties and find all with the same name

is this the intended behavior and when did it change?

Thanks
Raimund

Miroslav Rajcic

unread,
Sep 17, 2022, 2:43:27 AM9/17/22
to Notecase Pro
Hi Raimund,

I've checked the change log file and couldn't find any mention of this change.
It took some code archaeology, and it seems that this change was introduced in all the way back in 2014, i.e. old algorithm (one you prefer) was present in v3.8.9 and new one was introduced in the next version 3.9.1.

The idea is that property name is the key, and it is supposed to be unique within a note.
For me it is logical that this works like it works now.

What is your use case that requires you to have duplicated names/keys?

Regards,
  Miro


From: 'info.sim...@googlemail.com' via Notecase Pro <noteca...@googlegroups.com>
Sent: Wednesday, September 14, 2022 4:51 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: question re Nc_Note_CustProp_Append
 
--
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/9f4fc3a3-3e61-4b6f-bf23-207b2f885bbdn%40googlegroups.com.

Paul Merrell

unread,
Sep 17, 2022, 3:05:20 AM9/17/22
to Notecase Pro
When this issue is resolved, please let me know what change(s) should be made in the Help file.

Best regards,

Paul
 
--
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/9f4fc3a3-3e61-4b6f-bf23-207b2f885bbdn%40googlegroups.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...@googlegroups.com.


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

Miroslav Rajcic

unread,
Sep 17, 2022, 6:16:24 AM9/17/22
to Notecase Pro
Will do.

Regards,
  Miro

From: noteca...@googlegroups.com <noteca...@googlegroups.com> on behalf of Paul Merrell <mar...@gmail.com>
Sent: Saturday, September 17, 2022 9:05 AM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: question re Nc_Note_CustProp_Append
 

info.sim...@googlemail.com

unread,
Sep 17, 2022, 8:08:42 AM9/17/22
to Notecase Pro
Hi Miro,

I picked up enhancing my NCP solution (almost a kind of CRM solution now ;-) ) and implemented a feature to easily link notes between different files and also the "What links here" feature across different files. to do so I wanted to write the linked note information in the target note and always use the same custom property name. In the "What links here" routine I wanted to cycle trough all custom properties and compare against the custom property name I use to store the link information. But no worries - i simply did my own append routine in a library which takes the custom property name, appends a string "_counter" and adds the number to the provided custom property name. This way I can call my append routine with the custom property name without dealing with a counter or different custom property names.

my only suggestion for the help would be that, in case the custom property exists, the value will be overwritten and therefore has the same effect than Nc_Note_CustProp_SetValueByIdx but one uses the property name instead of the index

just my 2 cents ;-)

Raimund

Miroslav Rajcic

unread,
Sep 19, 2022, 8:41:47 AM9/19/22
to Notecase Pro, Paul Merrell
Thanks Raimund,

so I guess you are OK with the change.
I did test the code and as far as I can see, ..._Append call does overwrite the value of the existing key correctly (script pasted in PS. below).

@Paul Merrell, can you update the help to document the new/current behavior of the API:
  • if the custom property with the name parameter already exists, instead of adding a new item, the code will just update the value of the code property having a matching name
  • we only update the first match found, search starting from index 0 onwards
Regards,
  Miro

PS. Test script (appends same custom property key twice to the same note):

--get IDs of current document and note
local nDocID = Nc_Doc_ID_GetCur()
local strNoteID = Nc_Note_ID_GetCur(nDocID)

-- check to see if note is selected and abort the script if not
if strNoteID == "" then
  Nc_GUI_InfoBox("ERROR: A note must be selected before executing this action. Execution was terminated.", 1, "ERROR")
  return
end

Nc_Note_CustProp_Append(nDocID, strNoteID, "EventDate", "aaa")
Nc_Note_CustProp_Append(nDocID, strNoteID, "EventDate", "bbb")


Sent: Saturday, September 17, 2022 2:08 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: Re: question re Nc_Note_CustProp_Append
 

info.sim...@googlemail.com

unread,
Sep 20, 2022, 4:24:35 AM9/20/22
to Notecase Pro
Hi Miro,

that's fine - no problem with that. One just need to know it ;-)

best regards

Raimund

Paul Merrell

unread,
Sep 20, 2022, 1:25:35 PM9/20/22
to Miroslav Rajcic, Notecase Pro
On Mon, Sep 19, 2022 at 5:41 AM Miroslav Rajcic <mra...@hotmail.com> wrote:
 
@Paul Merrell, can you update the help to document the new/current behavior of the API:
  • if the custom property with the name parameter already exists, instead of adding a new item, the code will just update the value of the code property having a matching name
  • we only update the first match found, search starting from index 0 onwards

Will do. 

Best regards,

Paul

--
Reply all
Reply to author
Forward
0 new messages