{"id":13301,"date":"2026-10-06T10:03:05","date_gmt":"2026-10-06T10:03:05","guid":{"rendered":"https:\/\/www.fhug.org.uk\/kb\/?post_type=kb_article&#038;p=13301"},"modified":"2026-10-06T10:03:05","modified_gmt":"2026-10-06T10:03:05","slug":"writing-plugins-compatible-with-versions-7-8","status":"publish","type":"kb_article","link":"https:\/\/www.fhug.org.uk\/kb\/kb-article\/writing-plugins-compatible-with-versions-7-8\/","title":{"rendered":"Writing and Maintaining Plugins Compatible with Versions 7 and 8"},"content":{"rendered":"<blockquote>\n<p><strong>This article is a work in progress.<\/strong> It brings together what plugin authors have found so far while updating their plugins for <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8, and it will grow as more turns up. If you&#8217;ve come across something that isn&#8217;t covered here, or something here turns out to be wrong, please say so in <a href=\"https:\/\/fhug.org.uk\/forum\/viewtopic.php?&t=24742\">Are there any adjustments to make to FH7 Plugins for FH8?<\/a> on the FHUG Forums.<\/p>\n<\/blockquote>\n<h2>Introduction<\/h2>\n<p>Most plugins written for <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 run in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 without any changes. Version 8 does change a few things underneath, though, and plugins that touch those areas may need work. This article lists the areas to check and the new facilities that are available to you. It assumes you&#8217;re already familiar with writing plugins for <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7; for earlier versions see <a href=\"\/kb\/kb-article\/writing-plugins-compatible-with-versions-5-6-7\/\">Writing and Maintaining Plugins Compatible with Versions 5, 6 &amp; 7<\/a>.<\/p>\n<p>The Plugin Help&#8217;s own summary of the changes is <a href=\"https:\/\/www.family-historian.co.uk\/help\/fh8plugins\/new_in_version_8.htm\" target=\"_blank\" rel=\"noopener noreferrer\">What&#8217;s New in Version 8?<\/a>. It also has a new section, <em>Item Pointers: Confusions and Pitfalls to Avoid<\/em>, which Calico Pie recommend to all plugin authors.<\/p>\n<h2>Testing Alongside Version 7<\/h2>\n<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 installs alongside <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 rather than replacing it, so you can test a plugin in both on the same PC. Each version keeps its own settings and its own copy of your plugins. When <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 is first installed it copies your plugins across from <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7, but after that the two are independent: updating a plugin in one version doesn&#8217;t update it in the other. If you&#8217;re testing a new version of a plugin in both, load it into each.<\/p>\n<p>When a plugin has been tested, mark it as compatible with Version 8 in the Plugin Store. Users are advised to check that before relying on a plugin (see <a href=\"\/kb\/kb-article\/using-plugins-in-version-8\/\">Using Plugins in Version 8<\/a>).<\/p>\n<h2>Folders, Files and the Registry<\/h2>\n<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 uses different application and program data folders from <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 (paths ending in <code>Family Historian 8<\/code> instead of <code>Family Historian<\/code>). A plugin with a hard-coded path into a <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 folder will either fail or, worse, quietly read <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7&#8217;s files. Use <code>fhGetContextInfo<\/code> and <code>fhGetPluginDataFileName<\/code> to reference the locations applicable to your environment.<\/p>\n<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 introduces one additional program data folder: <code>Smart Folders<\/code>.<\/p>\n<p>Registry keys are now under <em>Family Historian 8<\/em> rather than <em>Family Historian<\/em>. A plugin that reads <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>&#8216;s settings from the Registry needs to look in the right place for the version it&#8217;s running in.<\/p>\n<h2>64-bit<\/h2>\n<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 is a 64-bit program, and all the Lua libraries that come with it are 64-bit. If your plugin uses a compiled library that you supply yourself (a DLL), you&#8217;ll need a 64-bit version of it; the 32-bit one won&#8217;t load.<\/p>\n<p>Plugins written purely in Lua are unaffected by the change itself, but timing can be. At least one well-known plugin that uses luacom to work with Windows ran into timing problems during the beta, so test anything that drives Windows or another program through luacom with particular care. Using luacom to create a <code>FileSystemObject<\/code> directly, rather than through fhFileUtils, works as before (although fhFileUtils works too).<\/p>\n<h2>Libraries<\/h2>\n<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 comes with the LPEG pattern-matching library and its <code>re<\/code> module, which <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 didn&#8217;t. They make it practical to use regular-expression-style patterns where Lua patterns fall short. If a plugin uses them and must also run in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7, it will need a fallback there.<\/p>\n<p>Most of the other bundled libraries are the same versions as in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7. The exception is LuaFileSystem (lfs), which reports version 1.6.3 in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8 against 1.7 in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7. If your plugin relies on anything added in 1.7, test it carefully; <code>lfs._VERSION<\/code> tells you which version you have.<\/p>\n<h2>Addresses<\/h2>\n<p>Version 8 adds a new record type, Address (<code>_ADDR<\/code>). Every address in an event or attribute now corresponds to an Address record, which in turn belongs to a Place record and can hold a map location, pictures and notes.<\/p>\n<p>If your plugin reads and writes addresses with <code>fhGetValueAsText<\/code> and <code>fhSetValueAsText<\/code>, little changes: address fields can still be treated as text. You need to take more care if you:<\/p>\n<ul>\n<li>work with Address records directly<\/li>\n<li>use <code>fhSetValueAsLink<\/code> or <code>fhSetValue_Copy<\/code> to set address fields (<code>fhSetValueAsLink<\/code> can now link an address field to an Address record, but it can fail if used incorrectly)<\/li>\n<li>check the value type of a field, since there is a new value type, <code>address<\/code>.<\/li>\n<\/ul>\n<p>If any of these apply, read <a href=\"https:\/\/www.family-historian.co.uk\/help\/fh8plugins\/api\/special_issues_with_place_and_address_fields.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Special Issues with Place and Address Fields<\/a>, which covers Address records alongside Place records. <code>fhGetValueAsLink<\/code> on an address field returns its Address record, and data references can follow the same link.<\/p>\n<h2>Named Lists<\/h2>\n<p>There is a new Named List object. <code>fhGetNamedListCount<\/code> tells you how many lists the project has, and <code>fhGetNamedList<\/code> or <code>fhGetNamedListByIndex<\/code> returns one; its methods are <code>GetName<\/code>, <code>GetItemCount<\/code> and <code>GetItem<\/code>. Plugins that read named lists some other way still work in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8, but the new functions are simpler.<\/p>\n<p>The object is read-only. There is no way for a plugin to create a named list, add records to one or change its notes. If you need a plugin to leave behind a set of records for the user, a Research Note with links to them (displayed via the new <code>fhOutputNote<\/code> function), or a temporary flag on each, will do the job.<\/p>\n<h2>Other Additions to the API<\/h2>\n<ul>\n<li><code>fhGetRecordLinks(ptr)<\/code> returns a table of all the links to a record.<\/li>\n<li><code>fhOutputNote(ptr)<\/code> displays a note field, Note record or Research Note record in the Note Window when the plugin finishes.<\/li>\n<li><code>fhGetFlagTag<\/code> has a new parameter for working with custom fact flags.<\/li>\n<li>Report plugins: the Section object has a new method, <code>SetOwner<\/code>, which sets which records appear in the <em>Page Records<\/em> list in the Reports and Book Windows, and <code>AddPicture<\/code> has a new optional parameter, <code>bForceFull<\/code>.<\/li>\n<li>The 21 new built-in functions, such as <code>GetResolvedText<\/code>, can be called from a plugin with <code>fhCallBuiltInFunction<\/code>, like any other built-in. See <a href=\"https:\/\/www.family-historian.co.uk\/help\/fh8\/fn_new_in_8.html\" target=\"_blank\" rel=\"noopener noreferrer\">New Functions (added in version 8)<\/a>.<\/li>\n<li>Smart Folder plugins are a new special plugin type, with a single entry point, <code>FH_GetSmartFolderData<\/code>. See <a href=\"https:\/\/www.family-historian.co.uk\/help\/fh8plugins\/special\/special.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Special Plugin Types<\/a> in the Plugin Help.<\/li>\n<\/ul>\n<h2>Supporting Both Versions<\/h2>\n<p>If a plugin is to run in both <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7 and <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>8, check the version before calling anything that only exists in Version 8:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">if fhGetAppVersion() &gt;= 8 then\r\n   -- Version 8 only, e.g. fhGetNamedList()\r\nend\r\n<\/pre>\n<p>Test with <code>&gt;=<\/code>, not <code>==<\/code>, so the code still works in later versions. It&#8217;s worth searching existing plugins for tests such as <code>fhGetAppVersion() == 7<\/code>, which will now be false.<\/p>\n<p>Last checked against <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span> 8.0.1. If you&#8217;ve found something else that belongs here, please tell us in <a href=\"https:\/\/fhug.org.uk\/forum\/viewtopic.php?&t=24742\">Are there any adjustments to make to FH7 Plugins for FH8?<\/a>.<\/p>\n","protected":false},"template":"","fh_version":[739,826],"skill_level":[18],"topic":[73],"class_list":["post-13301","kb_article","type-kb_article","status-publish","hentry","fh_version-v7","fh_version-v8","skill_level-advanced","topic-writing-plugins"],"_links":{"self":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/kb_article\/13301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/kb_article"}],"about":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/types\/kb_article"}],"wp:attachment":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/media?parent=13301"}],"wp:term":[{"taxonomy":"fh_version","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/fh_version?post=13301"},{"taxonomy":"skill_level","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/skill_level?post=13301"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/topic?post=13301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}