I create To Do facts to remind myself of records that need my attention. I have a custom query that searches for these facts and produces a report and have been saving these reports as a note in Evernote. I also add the individuals to a Named List but it doesn't seem possible to manipulate a Named List from a plugin so I thought I would try an alternative approach - a better (quicker) way of collecting together my To Do facts and adding them to an Evernote note.
The following is a plugin I have put together to automate the task. It searches for the facts, collects them in a table then exports them to a text file that gets stored in Evernote's default import folder. Evernote constantly scans that folder and automatically creates a note with any new file it finds.
There are probably better ways to achieve the same result and maybe further enhancements that could be added but as a bare minimum, it works for me.
All comments welcome.
Code: Select all
--[[
@Title: Search for and Export To Do facts
@Author: Robin Lasbury
@Version: 1.0
@LastUpdated: 14 May 2019
@Search for To Do facts and export the results to a text file in the default Evernote import folder,
allowing Evernote to automatically create a note with the contents.
]]
local ptrIndi = fhNewItemPtr()
local ptrFact = fhNewItemPtr()
local ptrRIN = fhNewItemPtr()
local ptrName = fhNewItemPtr()
local ptrToDo = fhNewItemPtr()
local ptrNote = fhNewItemPtr()
local strRIN
local strName
local strToDo
local strNote
local tblFile = {}
function OpenFile(strFileName,strMode)
local fileHandle, strError = io.open(strFileName,strMode)
if not fileHandle then
error("\n Unable to open file in \""..strMode.."\" mode. \n "..strFileName.." \n "..tostring(strError).." \n")
end
return fileHandle
end -- function OpenFile
-- Save string to file --
function SaveStringToFile(strString,strFileName)
local fileHandle = OpenFile(strFileName,"w")
fileHandle:write(strString)
assert(fileHandle:close())
end -- function SaveStringToFile
-- Loop through records --
function records(type)
local pi = fhNewItemPtr()
local p2 = fhNewItemPtr()
pi:MoveToFirstRecord(type)
return function ()
p2:MoveTo(pi)
pi:MoveNext()
if p2:IsNotNull() then return p2 end
end
end
-- Main program --
table.insert(tblFile, "==================================")
table.insert(tblFile, "Note Created: " .. os.date("%c"))
table.insert(tblFile, "==================================")
for ptrIndi in records('INDI') do
ptrFact = fhGetItemPtr(ptrIndi,'INDI._ATTR-TO_DO')
if ptrFact:IsNotNull() then
strRIN = fhGetRecordId(ptrIndi)
ptrName:MoveTo(ptrIndi,"INDI.NAME")
strName = fhGetValueAsText(ptrName)
ptrToDo:MoveTo(ptrFact,"_ATTR-TO_DO")
strToDo = fhGetValueAsText(ptrToDo)
ptrNote:MoveTo(ptrFact,"_ATTR-TO_DO.NOTE2")
strNote = fhGetValueAsText(ptrNote)
table.insert(tblFile, "RIN: " .. strRIN)
table.insert(tblFile, "Name: " .. strName)
table.insert(tblFile, "Category: " .. strToDo)
table.insert(tblFile, "Note: " .. strNote)
table.insert(tblFile, "==================================")
end
end
SaveStringToFile(table.concat(tblFile,"\n").."\n","D:\\Genealogy\\To Evernote\\Latest To Do.txt")
fhMessageBox('To Do Note exported to Evernote')