Page 1 of 1

Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 12:13
by shoshk
I know it's a stupid question, but I can't find the answer, so...

I have the following code:

pNote = fhGetValueAsLink(pi, '~.NOTE2')

where pi points to a _PLAC record. I've tried several variations on the data reference. All return 'null'. I guess I'm missing a period or something.

Can you help?

Thanks,
Shosh

Re: Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 12:17
by shoshk
OK. Really was a stupid question. :oops:

I forgot that I had to create the note if it didn't exist.

All works now.

Shosh

Re: Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 12:42
by Jane
Were you meaning strText =fhGetValueAsText(ptr) as NOTE2 is a local note there should be no link to another record.

Re: Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 12:45
by shoshk
Ok, still having a problem.

pNote = fhGetValueAsLink(pi, '~.NOTE2') always returns null.

So then I
if pNote:IsNull() then
pNote = fhCreateItem('NOTE2', pi)
end
fhSetValueAsText(pNote, sNote)

which creates a new note for the place. Every time I run the plugin. Which is not what I want. Argh!

Re: Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 13:20
by Jane
As I said you can't get a "link" to the Note as the note2 is local and and not a separate record.

Try the following

Code: Select all

local pNote = fhNewItemPtr()

pNote:MoveTo(pi,'~.NOTE2')

if pNote:IsNull() then
pNote = fhCreateItem('NOTE2', pi)
end

fhSetValueAsText(pNote, sNote)
 

Re: Getting the pointer to a _PLACE note

Posted: 11 Oct 2019 13:26
by shoshk
Got it working. The correct syntax is:

pNote = fhGetItemPtr(pi, '~.NOTE2')

Thanks for helping.

Shosh