Note Records.fh_lua

--[[
@Title: Note Records
@Type: Report
@Author: Calico Pie
@Version: 1.1
@Keywords: Notes
@LastUpdated:  8 Dec 2020
@Licence: This plugin is copyright (c) 2020 Calico Pie & contributors and is licensed under the MIT License
which is hereby incorporated by reference (see https://pluginstore.family-historian.co.uk/fh-plugin-licence)
@Description:


@Description: Report on one or more Note records
]]

------------------------------------------------------------
-- FH_Requirements
------------------------------------------------------------
function FH_Requirements()
	local t = {};

	-- default startup options
	t.record_type = "NOTE";
	t.generations = false;	

	-- report options dialog requirements
	t.tabs = "sources,format";  -- report options tabs required (may not show in rpt opts when report is part of a book)
	t.fonts = "hdg1,secdata,seclabel";	-- fonts shown in format tab of report options
	t.heading_levels = 1;		-- affects no. of heading levels shown in format tab of report options
	t.column_indents = 0;		-- no. of column indent value required in layout tab of rpt opts
	t.para_indent = false;		-- para indent value required in layout tab of rpt opts

	return t;
end

------------------------------------------------------------
-- FH_GetRecordSectionContent
------------------------------------------------------------
function FH_GetRecordSectionContent(snTop, rec, index, count)

	local rt

	pr = fhNewItemPtr();
	pr:MoveTo(rec, "~.TEXT");

	if pr:IsNull() then
		rt = fhNewRichText("(no text)")
	else
		rt = fhGetValueAsRichText(pr);	
	end
	
	local rtHeading = fhNewRichText();
	rtHeading:SetText(fhFtfEncode(fhGetDisplayText(rec)));
	snTop:SetHeading(rtHeading);



	-- Append all Text Level and Record Level Sources to end of report
		rt:AddCitation(pr,true)
		rt:AddCitation(rec)

	snTop:SetBodyText(rt);
end   



------------------------------------------------------------
-- Main
------------------------------------------------------------
if DEBUG_MODE then
	sn = fhNewSection();
	pr = fhNewItemPtr();
	pr:MoveToFirstRecord("NOTE");
	FH_GetRecordSectionContent(sn, pr, 1, 1);
end

Source:Note-Records-1.fh_lua