* How to create _FILE and FORM fields in OBJE record

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
avatar
TSG
Gold
Posts: 21
Joined: 07 Sep 2011 11:52
Family Historian: V6
Contact:

How to create _FILE and FORM fields in OBJE record

Post by TSG » 17 Jan 2012 18:14

If I create a new OBJE record from within a plugin I either get duplicate FORM and _FILE fields or blanks.

e.g. If I do:

local objFILE=fhCreateItem('TITL',objOBJE) fhSetValueAsText(objFILE, 'mytestfile.jpg')

... the record is created with 2 FILEs - one blank and one with the test file in it.

I thought it might be because the FILE and FORM were mandatory and so pre-set so tried this instead:

local objFILE=fhGetItemPtr(objOBJE,'_FILE')
fhSetValueAsText(objFILE, 'mytestfile.jpg')

That gets rid of the duplicate FILE but doesn't set the test file at all.

I even tried deleting it and re-creating or re-setting it in the code but no joy.

Is this a bug or am I doing something wrong?

ID:5822

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

How to create _FILE and FORM fields in OBJE record

Post by Jane » 17 Jan 2012 18:48

You need the 'navigation' data reference for the get eg:

local objFILE=fhGetItemPtr(objOBJE,'~._FILE')

I would also check if objFile is nil and if it is then create it.

Also make sure you have Beta 5.0.4 and not an earlier one, as I thought the latest version did not add title and filem but I have not double checked it.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

avatar
TSG
Gold
Posts: 21
Joined: 07 Sep 2011 11:52
Family Historian: V6
Contact:

How to create _FILE and FORM fields in OBJE record

Post by TSG » 17 Jan 2012 19:20

The ~ solved it - many thanks :)

Post Reply