{"id":12476,"date":"2022-11-06T17:16:34","date_gmt":"2022-11-06T17:16:34","guid":{"rendered":"https:\/\/fhug.org.uk\/kb\/?post_type=kb_article&#038;p=12476"},"modified":"2022-11-06T17:16:34","modified_gmt":"2022-11-06T17:16:34","slug":"lua-code-snippets","status":"publish","type":"kb_article","link":"https:\/\/www.fhug.org.uk\/kb\/kb-article\/lua-code-snippets\/","title":{"rendered":"Lua Code Snippets"},"content":{"rendered":"<p>Plugin developers may find these Lua snippets useful. Some of them implement frequently-needed tasks; others illustrate more specialist techniques.\u00a0 Please ask in the <a href=\"https:\/\/www.fhug.org.uk\/forum\/viewforum.php?f=42\">FHUG Plugin Discussions Forum<\/a> if you need help to adapt them for your purpose.<\/p>\n<p>Also, in V7, consider using the fhUtils, fhFileUtils, and fhSQL libraries which have superseded some of the snippets.<\/p>\n<p>Use the copy to clipboard function within a snippet to use in your own code.<\/p>\n<div><ul id=\"kblist\"><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/dates\"><h4>Dates<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/dates\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/external-databases\"><h4>External Databases<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/external-databases\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/file-and-folder-management\"><h4>File and Folder Management<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/file-and-folder-management\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/looping-iterating\"><h4>Looping\/Iterating<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/looping-iterating\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/other\"><h4>Other<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/other\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/plugin-related-lua-programming\"><h4>Plugin-related \/ Lua \/ Programming<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/plugin-related-lua-programming\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/project-database-admin\"><h4>Project Database Admin<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/project-database-admin\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/strings\"><h4>Strings<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/strings\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/system\"><h4>System<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/system\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/user-interface\"><h4>User Interface<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/user-interface\">All<\/a><\/li><\/ul><\/li><li class=\"kb-topic\"><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/web\"><h4>Web<\/a><\/h4><ul><li><a href=\"https:\/\/www.fhug.org.uk\/kb\/snippet-category\/web\">All<\/a><\/li><\/ul><\/li><\/ul><\/div>\n","protected":false},"template":"","fh_version":[14,15,739],"skill_level":[18],"topic":[73],"class_list":["post-12476","kb_article","type-kb_article","status-publish","hentry","fh_version-v5","fh_version-v6","fh_version-v7","skill_level-advanced","topic-writing-plugins"],"_links":{"self":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/kb_article\/12476","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=12476"}],"wp:term":[{"taxonomy":"fh_version","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/fh_version?post=12476"},{"taxonomy":"skill_level","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/skill_level?post=12476"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/topic?post=12476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}