{"id":7225,"date":"2014-08-07T04:09:05","date_gmt":"2014-08-07T11:09:05","guid":{"rendered":"http:\/\/www.seedcode.com\/?p=7225"},"modified":"2023-02-23T22:47:51","modified_gmt":"2023-02-23T22:47:51","slug":"javascript-functions-filemaker","status":"publish","type":"post","link":"https:\/\/seedcode.com\/javascript-functions-filemaker\/","title":{"rendered":"JavaScript Functions in FileMaker"},"content":{"rendered":"<h2>JavaScript Functions for Speed and Profit<\/h2>\n<p>The movie below is from one of our most popular demos from &#8220;Year in Review&#8221; at DevCon 2014. I was talking about what a breakthrough custom functions were back in 2004 and how they unlocked a whole new kind of code-sharing among FileMaker developers.&nbsp;JavaScript functions in FileMaker may unlock even more potential.<\/p>\n<p>Jason Young introduced the idea of using JavaScript as a calculator&#8211;as a library of functions&#8211;instead of using it for perhaps the more obvious purpose of building interface elements. (<a href=\"\/filemaker-webviewer-javascript-calculation-engine\/\">Jason&#8217;s original article on this<\/a> can be seen as part 1 of this post.) This gives us a huge opportunity to share and borrow code from the immense catalogue of JavaScript functions and examples.<\/p>\n<figure id=\"attachment_7237\" aria-describedby=\"caption-attachment-7237\" style=\"width: 300px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.seedcode.com\/wp-content\/uploads\/2014\/08\/cfs.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-medium wp-image-7237 \" src=\"http:\/\/www.seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-300x273.png\" alt=\"FileMaker Custom Functions Forum\" width=\"300\" height=\"273\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-300x273.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-1024x932.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-768x699.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-1536x1399.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/cfs-2048x1865.png 2048w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-7237\" class=\"wp-caption-text\">FileMaker engineers start posting custom functions to a public forum: March 2004<\/figcaption><\/figure>\n<p>As just one example, we (Jason) rewrote the venerable &#8220;namwoB&#8221; function in JavaScript. namwoB was the first recursive functions I ever saw and was posted by Andy LeCates back in March of 2004. The title comes from Court Bowman&#8217;s name spelled backwards&#8230; which is all the functions does, rewriting a string of text in reverse. This simplicity makes it a great way to talk about the different kinds of recursion in FileMaker and what a faster version of the function might look like in JavaScript.<\/p>\n<p>Our example file shows the same recursive custom functions done as a &#8220;stack&#8221; recursive function (limited to about 10k loops), as a &#8220;tail&#8221; recursive function (limited to 49,999 loops), and as a JavaScript function executed in a webviewer and then passed into a FileMaker script.<\/p>\n<p><a style=\"line-height: 1.5em;\" href=\"https:\/\/seedcode.com\/wp-content\/uploads\/2023\/02\/namwoB_JS.fmp12.zip\">Download the example file<\/a><span style=\"line-height: 1.5em;\">.&nbsp;<\/span><\/p>\n<h2>JavaScript Functions in FileMaker are&nbsp;Fast<\/h2>\n<p>Looping through 49,000 characters took our tail-recursive custom function almost 3 seconds.<\/p>\n<p>The JavaScript version of the function looped through 10 times that much text&#8211;nearly 500,000 characters&#8211;in 3\/10ths of a second.<\/p>\n<p>And thanks to the improved <a href=\"http:\/\/www.twdesigns.com\/fmp_url_protocol\/\">fmp&nbsp;url in FileMaker 13<\/a>, we can grab the results of functions like these quite easily. The movie below demos this and walks through our example file. It also gives a nice side-effect-demo of how webviewers get their own thread in FileMaker Pro and what that may mean for trying to measure performance.<\/p>\n<p style=\"text-align: center;\"><\/p>\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"JavaScript Functions in FileMaker (Speed)\" width=\"960\" height=\"540\" src=\"https:\/\/www.youtube.com\/embed\/Lgm3XvUDcmA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript Functions for Speed and Profit The movie below is from one of our most popular demos from &#8220;Year in Review&#8221; at DevCon 2014. I was talking about what a breakthrough custom functions were back in 2004 and how they unlocked a whole new kind of code-sharing among FileMaker developers.&nbsp;JavaScript functions in FileMaker may unlock even more potential. Jason Young introduced the idea of using JavaScript as a calculator&#8211;as a library of functions&#8211;instead of using it for perhaps the more obvious purpose of building interface elements. (Jason&#8217;s original article on this can be seen as part 1 of this post.) This gives us a huge opportunity to share and borrow code from the immense catalogue of JavaScript functions and examples. As just one example, we (Jason) rewrote the venerable &#8220;namwoB&#8221; function in JavaScript. namwoB was the first recursive functions I ever saw and was posted by Andy LeCates back in March of 2004. The title comes from Court Bowman&#8217;s name spelled backwards&#8230; which is all the functions does, rewriting a string of text in reverse. This simplicity makes it a great way to talk about the different kinds of recursion in FileMaker and what a faster version of the function might look like in JavaScript. Our example file shows the same recursive custom functions done as a &#8220;stack&#8221; recursive function (limited to about 10k loops), as a &#8220;tail&#8221; recursive function (limited to 49,999 loops), and as a JavaScript function executed in a webviewer and then passed into a FileMaker script. Download the example file.&nbsp; JavaScript Functions in FileMaker are&nbsp;Fast Looping through 49,000 characters took our tail-recursive custom function almost 3 seconds. The JavaScript version of the function looped through 10 times that much text&#8211;nearly 500,000 characters&#8211;in 3\/10ths of a second. And thanks to the improved fmp&nbsp;url in FileMaker 13, we can grab the results of functions like these quite easily. The movie below demos this and walks through our example file. It also gives a nice side-effect-demo of how webviewers get their own thread in FileMaker Pro and what that may mean for trying to measure performance.<\/p>\n","protected":false},"author":1,"featured_media":7243,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,23],"class_list":["post-7225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-filemaker-13","tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Functions in FileMaker - SeedCode<\/title>\n<meta name=\"description\" content=\"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker&#039;s web viewers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Functions in FileMaker - SeedCode\" \/>\n<meta property=\"og:description\" content=\"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker&#039;s web viewers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\" \/>\n<meta property=\"og:site_name\" content=\"SeedCode\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/seedcoder\" \/>\n<meta property=\"article:published_time\" content=\"2014-08-07T11:09:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-23T22:47:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png\" \/>\n\t<meta property=\"og:image:width\" content=\"109\" \/>\n\t<meta property=\"og:image:height\" content=\"110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"seedcode\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dayback\" \/>\n<meta name=\"twitter:site\" content=\"@dayback\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"seedcode\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\"},\"author\":{\"name\":\"seedcode\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/af42f3f8cbfc8652fb0ffbb3f46f260f\"},\"headline\":\"JavaScript Functions in FileMaker\",\"datePublished\":\"2014-08-07T11:09:05+00:00\",\"dateModified\":\"2023-02-23T22:47:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\"},\"wordCount\":376,\"commentCount\":11,\"publisher\":{\"@id\":\"https:\/\/seedcode.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png\",\"keywords\":[\"FileMaker 13\",\"javascript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\",\"url\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\",\"name\":\"JavaScript Functions in FileMaker - SeedCode\",\"isPartOf\":{\"@id\":\"https:\/\/seedcode.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png\",\"datePublished\":\"2014-08-07T11:09:05+00:00\",\"dateModified\":\"2023-02-23T22:47:51+00:00\",\"description\":\"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker's web viewers.\",\"breadcrumb\":{\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/seedcode.com\/javascript-functions-filemaker\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage\",\"url\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png\",\"contentUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png\",\"width\":109,\"height\":110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/seedcode.com\/javascript-functions-filemaker\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/seedcode.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Functions in FileMaker\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/seedcode.com\/#website\",\"url\":\"https:\/\/seedcode.com\/\",\"name\":\"SeedCode\",\"description\":\"Build the Software You&#039;ve Always Wanted\",\"publisher\":{\"@id\":\"https:\/\/seedcode.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/seedcode.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/seedcode.com\/#organization\",\"name\":\"SeedCode\",\"url\":\"https:\/\/seedcode.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png\",\"contentUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png\",\"width\":595,\"height\":189,\"caption\":\"SeedCode\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/seedcoder\",\"https:\/\/x.com\/dayback\",\"https:\/\/www.linkedin.com\/company\/seedcode\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/af42f3f8cbfc8652fb0ffbb3f46f260f\",\"name\":\"seedcode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f0c386c5b845ee7fe111b36b2d87e983811f1f549682de9597a934b9dfd45469?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f0c386c5b845ee7fe111b36b2d87e983811f1f549682de9597a934b9dfd45469?s=96&d=mm&r=g\",\"caption\":\"seedcode\"},\"sameAs\":[\"https:\/\/seedcode.com\"],\"url\":\"https:\/\/seedcode.com\/author\/seedcode\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Functions in FileMaker - SeedCode","description":"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker's web viewers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/seedcode.com\/javascript-functions-filemaker\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Functions in FileMaker - SeedCode","og_description":"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker's web viewers.","og_url":"https:\/\/seedcode.com\/javascript-functions-filemaker\/","og_site_name":"SeedCode","article_publisher":"https:\/\/www.facebook.com\/seedcoder","article_published_time":"2014-08-07T11:09:05+00:00","article_modified_time":"2023-02-23T22:47:51+00:00","og_image":[{"width":109,"height":110,"url":"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png","type":"image\/png"}],"author":"seedcode","twitter_card":"summary_large_image","twitter_creator":"@dayback","twitter_site":"@dayback","twitter_misc":{"Written by":"seedcode","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#article","isPartOf":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/"},"author":{"name":"seedcode","@id":"https:\/\/seedcode.com\/#\/schema\/person\/af42f3f8cbfc8652fb0ffbb3f46f260f"},"headline":"JavaScript Functions in FileMaker","datePublished":"2014-08-07T11:09:05+00:00","dateModified":"2023-02-23T22:47:51+00:00","mainEntityOfPage":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/"},"wordCount":376,"commentCount":11,"publisher":{"@id":"https:\/\/seedcode.com\/#organization"},"image":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage"},"thumbnailUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png","keywords":["FileMaker 13","javascript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/seedcode.com\/javascript-functions-filemaker\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/","url":"https:\/\/seedcode.com\/javascript-functions-filemaker\/","name":"JavaScript Functions in FileMaker - SeedCode","isPartOf":{"@id":"https:\/\/seedcode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage"},"image":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage"},"thumbnailUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png","datePublished":"2014-08-07T11:09:05+00:00","dateModified":"2023-02-23T22:47:51+00:00","description":"An example file and video comparing the speed of native FileMaker functions to JavaScript functions in FileMaker's web viewers.","breadcrumb":{"@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/seedcode.com\/javascript-functions-filemaker\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#primaryimage","url":"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png","contentUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2014\/08\/jscalc.png","width":109,"height":110},{"@type":"BreadcrumbList","@id":"https:\/\/seedcode.com\/javascript-functions-filemaker\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/seedcode.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript Functions in FileMaker"}]},{"@type":"WebSite","@id":"https:\/\/seedcode.com\/#website","url":"https:\/\/seedcode.com\/","name":"SeedCode","description":"Build the Software You&#039;ve Always Wanted","publisher":{"@id":"https:\/\/seedcode.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/seedcode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/seedcode.com\/#organization","name":"SeedCode","url":"https:\/\/seedcode.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/#\/schema\/logo\/image\/","url":"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png","contentUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png","width":595,"height":189,"caption":"SeedCode"},"image":{"@id":"https:\/\/seedcode.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/seedcoder","https:\/\/x.com\/dayback","https:\/\/www.linkedin.com\/company\/seedcode\/"]},{"@type":"Person","@id":"https:\/\/seedcode.com\/#\/schema\/person\/af42f3f8cbfc8652fb0ffbb3f46f260f","name":"seedcode","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f0c386c5b845ee7fe111b36b2d87e983811f1f549682de9597a934b9dfd45469?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f0c386c5b845ee7fe111b36b2d87e983811f1f549682de9597a934b9dfd45469?s=96&d=mm&r=g","caption":"seedcode"},"sameAs":["https:\/\/seedcode.com"],"url":"https:\/\/seedcode.com\/author\/seedcode\/"}]}},"_links":{"self":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts\/7225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/comments?post=7225"}],"version-history":[{"count":0,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts\/7225\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/media\/7243"}],"wp:attachment":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/media?parent=7225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/categories?post=7225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/tags?post=7225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}