{"id":12008,"date":"2019-05-22T17:47:31","date_gmt":"2019-05-22T17:47:31","guid":{"rendered":"https:\/\/www.directimpactsolutions.com\/?p=12008"},"modified":"2023-05-22T19:20:16","modified_gmt":"2023-05-22T19:20:16","slug":"while-loops-new-feature-in-filemaker","status":"publish","type":"post","link":"https:\/\/www.directimpactsolutions.com\/en\/while-loops-new-feature-in-filemaker\/","title":{"rendered":"While Loops \u2013 New Feature in FileMaker 18"},"content":{"rendered":"<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-1024x317.jpg\" alt=\"While Loops\" class=\"wp-image-12013\" width=\"798\" height=\"247\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-1024x317.jpg 1024w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-300x93.jpg 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-768x238.jpg 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-1536x476.jpg 1536w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-600x186.jpg 600w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops.jpg 2000w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/figure><p>While the Loop script step has been around since FileMaker 6, and recursive custom functions have been around since FileMaker 7, a native loop&nbsp;<em>function<\/em>&nbsp;that could be used within a calculation has remained a long awaited feature, until now!<\/p><h3 class=\"wp-block-heading\"><strong>The New \u2018While\u2019 Function in FileMaker 18<\/strong><\/h3><p>The \u2018While\u2019 function looks a lot like the \u2018Let\u2019 function at first, with a couple additional parameters that allow us to set a condition and perform recursive logic before producing a result:<\/p><pre class=\"wp-block-preformatted\">While (<br>      [ initVar1 = value1 ; initVar2 = value2 ; ...] ;<br>       condition ;<br>      [ logicVar1 = expression1 ; logicVar2 = expression2 ; ...] ;<br>      result<br>) <\/pre><h3 class=\"wp-block-heading\"><strong>When to Use It<\/strong><\/h3><p>The \u2018While\u2019 function can\u2019t and won\u2019t replace all loops, of course. There is no way to set a field or go to next record within a calculation, and these are often necessary steps within scripted loops. Also, functions are difficult to debug in general. Despite these deficiencies, we still found reasons why the \u2018While\u2019 function is useful and even preferable to the Loop script step when possible.<\/p><h3 class=\"wp-block-heading\"><strong>Slimmer\/Lighter Scripts<\/strong><\/h3><p>For example, we use a script called \u2018Add Record to JSON\u2019 in our fmLog module that can capture an entire record in JSON using eleven script steps:<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/Add-Record-to-JSON.png\" alt=\"\" class=\"wp-image-12009\" width=\"742\" height=\"471\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/Add-Record-to-JSON.png 967w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/Add-Record-to-JSON-300x190.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/Add-Record-to-JSON-768x488.png 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/Add-Record-to-JSON-600x381.png 600w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/figure><p>These eleven lines of code can now be reduced to a single script step of \u2018Set Variable\u2019 using the \u2018While\u2019 function:<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Function.png\" alt=\"\" class=\"wp-image-12011\" width=\"740\" height=\"386\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Function.png 1024w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Function-300x156.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Function-768x401.png 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Function-600x313.png 600w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/figure><h3 class=\"wp-block-heading\"><strong><strong>The While Function is Faster<\/strong><\/strong><\/h3><p>When we put it to the test using the example scripts above, we discovered that the \u2018While\u2019 function is faster than the \u2018Loop\u2019 script step! For every thousand records it\u2019s approximately one second faster. This is a noticeable difference when working with 10,000+ records, where an extra ten seconds can feel like an eternity.<\/p><p>I know we\u2019ll continue to find use cases for the \u2018While\u2019 function to shine, and we are thrilled to have the option when we need it. You can find additional documentation and examples provided by FileMaker&nbsp;<a href=\"https:\/\/www.filemaker.com\/products\/whats-new.html#fm-video-while-setrecursion-calculation\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. You\u2019ll even find some great examples of how the \u2018While\u2019 function can be nested within a \u2018Let\u2019 function for even more functionality!<\/p><p>If you have questions about the While function function, feel free to <a href=\"http:\/\/directimpactsolutions.com\/en\/contact-us\/\">contact us<\/a>!<\/p><hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"margin-top:var(--wp--preset--spacing--70);margin-bottom:var(--wp--preset--spacing--70)\"\/><p class=\"has-small-font-size\"><em>*This article was originally written for AppWorks, which has since joined Direct Impact Solutions. This article is intended for informative purposes only. To the best of our knowledge, this information is accurate as of the date of publication.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>While the Loop script step has been around since FileMaker 6, and recursive custom functions have been around since FileMaker 7, a native loop&nbsp;function&nbsp;that could be used within a calculation has remained a long awaited feature, until now! The New \u2018While\u2019 Function in FileMaker 18 The \u2018While\u2019 function looks a lot like the \u2018Let\u2019 function &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.directimpactsolutions.com\/en\/while-loops-new-feature-in-filemaker\/\"> <span class=\"screen-reader-text\">While Loops \u2013 New Feature in FileMaker 18<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":6,"featured_media":12013,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","footnotes":""},"categories":[29],"tags":[39,238,239],"class_list":["post-12008","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-low-code","tag-filemaker","tag-looping","tag-while-loops"],"uagb_featured_image_src":{"full":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops.jpg",2000,620,false],"thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-150x150.jpg",150,150,true],"medium":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-300x93.jpg",300,93,true],"medium_large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-768x238.jpg",768,238,true],"large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-1024x317.jpg",1024,317,true],"1536x1536":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-1536x476.jpg",1536,476,true],"2048x2048":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops.jpg",2000,620,false],"woocommerce_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-300x300.jpg",300,300,true],"woocommerce_single":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-600x186.jpg",600,186,true],"woocommerce_gallery_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/While-Loops-100x100.jpg",100,100,true]},"uagb_author_info":{"display_name":"Direct Impact Solutions","author_link":"https:\/\/www.directimpactsolutions.com\/en\/author\/direct-impact-solutions\/"},"uagb_comment_info":0,"uagb_excerpt":"While the Loop script step has been around since FileMaker 6, and recursive custom functions have been around since FileMaker 7, a native loop&nbsp;function&nbsp;that could be used within a calculation has remained a long awaited feature, until now! The New \u2018While\u2019 Function in FileMaker 18 The \u2018While\u2019 function looks a lot like the \u2018Let\u2019 function&hellip;","_links":{"self":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/12008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/comments?post=12008"}],"version-history":[{"count":2,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/12008\/revisions"}],"predecessor-version":[{"id":12338,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/12008\/revisions\/12338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media\/12013"}],"wp:attachment":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media?parent=12008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/categories?post=12008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/tags?post=12008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}