{"id":1675,"date":"2026-11-10T18:26:28","date_gmt":"2026-11-10T16:26:28","guid":{"rendered":"https:\/\/macromillcnc.com\/2026\/11\/10\/fanuc-macro-while-loop\/"},"modified":"2026-11-13T13:56:50","modified_gmt":"2026-11-13T11:56:50","slug":"fanuc-macro-while-loop","status":"publish","type":"post","link":"https:\/\/macromillcnc.com\/2026\/11\/10\/fanuc-macro-while-loop\/","title":{"rendered":"How a FANUC Macro WHILE Loop Works \u2014 Tip of the Iceberg"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A <strong>FANUC macro WHILE loop<\/strong> repeats a block of code for as long as its condition is true, then leaves when the test fails. In this lesson we follow a short MacroMill simulator video and walk through the pieces: the counter, the limit, the WHILE test, the body, the update and END. That loop is useful on its own, but it is only the tip of the iceberg of FANUC Custom Macro B. MacroMill\u2019s simulators and training are there to help you master the rest to perfection, safely, before the program reaches a real machine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What a FANUC macro WHILE loop does<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Plain G-code is a fixed list of moves. If you need four keyways around a C-axis, or a set of depth passes, you would otherwise copy the same blocks again and again. A WHILE loop does that repetition for you. The control tests the condition <em>before<\/em> each pass. If the test is true, it runs the body. If the test is false, it skips the body and continues after the matching END.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The examples below are simulator training fragments, taken from different programs in the lesson video. They are not one complete, machine-ready program. Verify any real machine program before use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The five parts of a FANUC macro WHILE loop<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Set the counter<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Start the count at zero. In the C-axis source program the counter is #110:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">#110=0;<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">2. Set the limit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">#101=4 means four keyways. With a +1 update, the counter will run from 0 to 3 \u2014 four passes \u2014 and then fail the test at 4.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">#101=4 (KEYWAY COUNT);<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">3. Test before each pass<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">LT means less than. The line asks: is #110 less than #101? DO1 opens loop number 1. That loop number must match END1.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">WHILE[#110 LT #101]DO1;<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" data-attachment-id=\"1671\" data-permalink=\"https:\/\/macromillcnc.com\/fanuc-macro-while-loop-test\/\" data-orig-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-title=\"FANUC macro WHILE loop test highlighted\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;The WHILE test is checked before every pass. LT means less than. DO1 must match END1.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?fit=1024%2C576&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=1920%2C1080&#038;ssl=1\" alt=\"FANUC program screen in the MacroMill simulator highlighting WHILE[#110 LT #101]DO1, the test that runs before each pass of a FANUC macro WHILE loop\" class=\"wp-image-1671\" srcset=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=1320%2C743&amp;ssl=1 1320w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-test.jpg?resize=600%2C338&amp;ssl=1 600w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">The WHILE test is checked before every pass. LT means less than. DO1 must match END1.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">4. Run the body<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the test is true, the control runs the body. In the C-axis example the body first calculates the keyway angle, then executes the moves inside the loop. With four keyways, each pass is 90 degrees apart:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">#111=360.0*#110\/#101;<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">5. Update the counter, then END1<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Add one to the counter so the next test sees a new value. The increment fragment in the lesson comes from another lathe program, used here to illustrate a +1 update with the C-axis source values:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">#110=#110+1;<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">END1 sends the control back to the WHILE test. True? Run again. False? Leave the loop and continue after END1.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code><div class=\"cm-line\">END1;<\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Step through: four keyways at 0\u00b0, 90\u00b0, 180\u00b0 and 270\u00b0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With #101=4 and a +1 counter update, the angle #111=360.0*#110\/#101 works out like this:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>#110<\/th><th>Test: #110 LT 4<\/th><th>Angle #111<\/th><\/tr><\/thead><tbody><tr><td>0<\/td><td>TRUE<\/td><td>0\u00b0<\/td><\/tr><tr><td>1<\/td><td>TRUE<\/td><td>90\u00b0<\/td><\/tr><tr><td>2<\/td><td>TRUE<\/td><td>180\u00b0<\/td><\/tr><tr><td>3<\/td><td>TRUE<\/td><td>270\u00b0<\/td><\/tr><tr><td>4<\/td><td>FALSE<\/td><td>Exit \u2014 continue after END1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Four true passes give four keyways, equally spaced around the C-axis. On the fifth test, 4 LT 4 is false. The body is skipped and the program continues after END1.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" data-attachment-id=\"1672\" data-permalink=\"https:\/\/macromillcnc.com\/fanuc-macro-while-loop-step-through\/\" data-orig-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-title=\"FANUC macro WHILE loop step-through\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Illustrative walkthrough with #101=4 and a +1 update: four true passes, then exit.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?fit=1024%2C576&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=1920%2C1080&#038;ssl=1\" alt=\"Step-through table in the MacroMill simulator showing a FANUC macro WHILE loop: counters 0 to 3 are true at 0, 90, 180 and 270 degrees, counter 4 is false and exits\" class=\"wp-image-1672\" srcset=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=1320%2C743&amp;ssl=1 1320w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?resize=600%2C338&amp;ssl=1 600w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">Illustrative walkthrough with #101=4 and a +1 update: four true passes, then exit.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The same repeat idea shows up in other work, not only C-axis indexing. The lesson also shows a different milling program, where each pass of a loop builds more toolpath in depth. The idea is the same: test, run the body, update, test again.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" data-attachment-id=\"1673\" data-permalink=\"https:\/\/macromillcnc.com\/fanuc-macro-while-loop-toolpath\/\" data-orig-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-title=\"WHILE loop milling depth-pass toolpath\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;A different program, same repeat idea: each pass adds more toolpath.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?fit=1024%2C576&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=1920%2C1080&#038;ssl=1\" alt=\"3D GRAPH view in the MacroMill FANUC VMC simulator showing a slot toolpath built up by repeated depth passes, illustrating the same WHILE loop repeat idea\" class=\"wp-image-1673\" srcset=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=1320%2C743&amp;ssl=1 1320w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-toolpath.jpg?resize=600%2C338&amp;ssl=1 600w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">A different program, same repeat idea: each pass adds more toolpath.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The common mistake: a loop that never exits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">What if the counter never changes? The test stays the same. With the limit fixed at 4, 0 LT 4 stays true, the body keeps running, and the loop never reaches its exit. Always check that the loop contains an update that will eventually make the condition false \u2014 and that DO and END use the same number.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" data-attachment-id=\"1674\" data-permalink=\"https:\/\/macromillcnc.com\/fanuc-macro-while-loop-infinite\/\" data-orig-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-title=\"FANUC macro WHILE loop missing counter update\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;A missing counter update is a classic infinite-loop mistake.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?fit=1024%2C576&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=1920%2C1080&#038;ssl=1\" alt=\"MacroMill simulator warning: if the counter in a FANUC macro WHILE loop never changes, 0 LT 4 stays true and the loop never exits\" class=\"wp-image-1674\" srcset=\"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=1320%2C743&amp;ssl=1 1320w, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-infinite.jpg?resize=600%2C338&amp;ssl=1 600w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">A missing counter update is a classic infinite-loop mistake. Find the counter, the test, the update and the END before you press Cycle Start.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Other comparison operators, and nesting DO1 to DO3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">LT is only one of the comparisons Custom Macro B gives you. The full set is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>EQ<\/strong> \u2014 equal to<\/li>\n\n\n\n<li><strong>NE<\/strong> \u2014 not equal to<\/li>\n\n\n\n<li><strong>GT<\/strong> \u2014 greater than<\/li>\n\n\n\n<li><strong>GE<\/strong> \u2014 greater than or equal to<\/li>\n\n\n\n<li><strong>LT<\/strong> \u2014 less than<\/li>\n\n\n\n<li><strong>LE<\/strong> \u2014 less than or equal to<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can also nest loops. FANUC Custom Macro B allows loop numbers DO1, DO2 and DO3, up to three levels deep. The number on END must match the number on DO. Do not nest a loop with the same number as an outer loop that is still open (DO1 inside DO1 is not allowed). After END1, a later DO1 is fine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">WHILE is just the tip of the iceberg<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the FANUC macro WHILE loop makes sense, you are looking at only one tool in Custom Macro B. The same language also gives you:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Variables<\/strong> \u2014 put changing numbers in # variables instead of hard-coding every size.<\/li>\n\n\n\n<li><strong>IF \/ GOTO<\/strong> \u2014 let the program choose a path, or raise a #3000 alarm when a value is wrong.<\/li>\n\n\n\n<li><strong>Arithmetic<\/strong> \u2014 angles, spacings, depths and trig, calculated at the control.<\/li>\n\n\n\n<li><strong>Subprogram calls with G65<\/strong> \u2014 pass arguments into a macro, like a function call, and reuse it from any program.<\/li>\n\n\n\n<li><strong>Parametric cycles<\/strong> \u2014 one proven program for a whole family of parts.<\/li>\n\n\n\n<li><strong>Probing logic<\/strong> \u2014 measure, compare to nominal, and update offsets or stop on a bad reading.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">That is how macros stop you rewriting the same program for every size, which we covered in <a href=\"https:\/\/macromillcnc.com\/2026\/11\/10\/cnc-macros-productivity-write-once\/\">Unlock CNC Macros Productivity on the Shop Floor \u2014 Write Once, Not Again<\/a>. The same WHILE pattern also drives rotary work, as in our <a href=\"https:\/\/macromillcnc.com\/2026\/11\/09\/4th-axis-cnc-simulator-fanuc-vmc-rotary\/\">4th axis CNC simulator<\/a> post. MacroMill\u2019s FANUC-style simulators and training are built so you can practise all of this \u2014 loops, variables, decisions, G65 calls and more \u2014 until you have mastered it to perfection, without risking a machine or a workpiece.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Simulator training only. The code shown here is verified fragments from different programs, not one complete machine-ready program. The walkthrough illustrates a +1 update with the C-axis source values; the counter-update fragment comes from another lathe program. The milling depth-pass footage is a different program demonstrating the same repeat idea. Check WHILE \/ DO \/ END syntax against your control\u2019s Custom Macro manual, and verify any real machine program before use.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Try it in the MacroMill simulator<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open a program, find the counter, the test, the update and the END, then single-block through the loop and watch the variables change.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/payhip.com\/b\/ETtyQ\" target=\"_blank\" rel=\"noopener\">C-Axis Lathe Simulator<\/a> \u2014 $69.99. The four-keyway example in this lesson is C-axis work.<\/li>\n\n\n\n<li><a href=\"https:\/\/payhip.com\/b\/W4hsw\" target=\"_blank\" rel=\"noopener\">MacroFusion\u2122<\/a> \u2014 helps turn repetitive, hard-coded G-code into reusable, variable-driven macro logic. $99.99 until 30 November.<\/li>\n\n\n\n<li><a href=\"https:\/\/payhip.com\/b\/9IpYU\" target=\"_blank\" rel=\"noopener\">CNC Automation Pro\u2122 2026<\/a> \u2014 Macro B from beginner to advanced, including loops, G65 arguments and #3000 alarms. $69.99.<\/li>\n\n\n\n<li><a href=\"https:\/\/payhip.com\/b\/vqdKz\" target=\"_blank\" rel=\"noopener\">All-In-One Bundle<\/a> \u2014 $149.99.<\/li>\n\n\n\n<li><a href=\"https:\/\/macromillcnc.com\/free-trial\/\">Free trial<\/a> \u2014 practise in the MacroMill FANUC-style simulators before you buy.<\/li>\n\n\n\n<li>Join the MacroMill WhatsApp group for tips and updates: <a href=\"https:\/\/chat.whatsapp.com\/Htae97asBiD14QiwMXjGJA\" target=\"_blank\" rel=\"noopener\">chat.whatsapp.com\/Htae97asBiD14QiwMXjGJA<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>MacroMill<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how a FANUC macro WHILE loop works: WHILE[&#8230;]DO1, the 0\/90\/180\/270 keyway walkthrough, and how MacroMill helps you master Macro B.<\/p>\n","protected":false},"author":279632934,"featured_media":1672,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_seo_llms_txt_always_include":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1378],"tags":[],"class_list":["post-1675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/phcvZP-r1","jetpack-related-posts":[{"id":1880,"url":"https:\/\/macromillcnc.com\/2026\/12\/03\/fanuc-macro-while-vs-if\/","url_meta":{"origin":1675,"position":0},"title":"WHILE vs IF in FANUC macros: a lesson on repeating and deciding","author":"MacroMill","date":"December 3, 2026","format":false,"excerpt":"A FANUC macro lesson on WHILE vs IF: IF decides once, WHILE repeats. See both work together in a real MacroMill depth loop and practise them in the simulator.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"WHILE and IF in a FANUC macro on the MacroMill simulator: O9011 shows WHILE[#154LT#110]DO2, an IF clamp and END2","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/12\/while-if-fanuc-macro-depth-loop.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/12\/while-if-fanuc-macro-depth-loop.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/12\/while-if-fanuc-macro-depth-loop.jpg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/12\/while-if-fanuc-macro-depth-loop.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/12\/while-if-fanuc-macro-depth-loop.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1836,"url":"https:\/\/macromillcnc.com\/2026\/11\/26\/write-test-and-run-a-fanuc-macro\/","url_meta":{"origin":1675,"position":1},"title":"Write a FANUC macro, test it in MacroMill, then run it on your machine","author":"MacroMill","date":"November 26, 2026","format":false,"excerpt":"Write and test a FANUC Custom Macro B program in a MacroMill simulator, then save or export it and run it on a real CNC machine after a normal prove-out.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"MacroMill VMC simulator for FANUC 0i-MF Plus style controls","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1827,"url":"https:\/\/macromillcnc.com\/2026\/11\/24\/how-to-choose-a-cnc-simulator\/","url_meta":{"origin":1675,"position":2},"title":"How to choose a CNC simulator for FANUC G-code and macro training","author":"MacroMill","date":"November 24, 2026","format":false,"excerpt":"A practical checklist for how to choose a CNC simulator for FANUC G-code and macro training, and a clear look at where MacroMill\u2019s simulators fit.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"MacroMill VMC simulator for FANUC 0i-MF Plus style controls","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1841,"url":"https:\/\/macromillcnc.com\/2026\/11\/26\/fanuc-macro-mistakes\/","url_meta":{"origin":1675,"position":3},"title":"Common FANUC macro mistakes that crash machines, and how to catch them first","author":"MacroMill","date":"November 26, 2026","format":false,"excerpt":"Common FANUC macro mistakes that crash machines, and how to catch them first with input checks, single block, and a test in a MacroMill simulator.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"MacroMill VMC simulator for FANUC 0i-MF Plus style controls","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-0i-mf-plus-vmc-simulator.png?fit=1080%2C1080&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1653,"url":"https:\/\/macromillcnc.com\/2026\/11\/09\/4th-axis-cnc-simulator-fanuc-vmc-rotary\/","url_meta":{"origin":1675,"position":4},"title":"4th Axis CNC Simulator: Program a Rotary A-Axis on a FANUC VMC","author":"MacroMill","date":"November 9, 2026","format":false,"excerpt":"Learn the MacroMill 4th axis CNC simulator: simultaneous X+A helical grooves, Macro B walkthrough, and FANUC VMC GRAPH views for safe practice.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"MacroMill FANUC VMC 4th axis CNC simulator showing finished diamond helical groove pattern on a cylinder held in a 3-jaw chuck with tailstock","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/4th-axis-cnc-simulator-finished-part.jpg?fit=1080%2C640&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/4th-axis-cnc-simulator-finished-part.jpg?fit=1080%2C640&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/4th-axis-cnc-simulator-finished-part.jpg?fit=1080%2C640&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/4th-axis-cnc-simulator-finished-part.jpg?fit=1080%2C640&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/4th-axis-cnc-simulator-finished-part.jpg?fit=1080%2C640&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1611,"url":"https:\/\/macromillcnc.com\/2026\/11\/08\/fanuc-cnc-simulators-built-in-cycles\/","url_meta":{"origin":1675,"position":5},"title":"FANUC CNC Simulators With Built-In Cycles: What MacroMill&#8217;s Simulators Solve","author":"MacroMill","date":"November 8, 2026","format":false,"excerpt":"Learn CNC without machine time, prove macros before cutting and generate code for threads, grooves, pockets and patterns. See the built-in cycles in MacroMill's FANUC-style lathe and VMC simulators.","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/macromillcnc.com\/category\/tutorials\/"},"img":{"alt_text":"MacroMill FANUC CNC simulator all-in-one bundle","src":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-simulator-all-in-one-bundle.png?fit=1080%2C1080&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-simulator-all-in-one-bundle.png?fit=1080%2C1080&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-simulator-all-in-one-bundle.png?fit=1080%2C1080&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-simulator-all-in-one-bundle.png?fit=1080%2C1080&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/macromill-fanuc-simulator-all-in-one-bundle.png?fit=1080%2C1080&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/macromillcnc.com\/wp-content\/uploads\/2026\/11\/fanuc-macro-while-loop-step-through.jpg?fit=1920%2C1080&ssl=1","_links":{"self":[{"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/posts\/1675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/users\/279632934"}],"replies":[{"embeddable":true,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/comments?post=1675"}],"version-history":[{"count":4,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/posts\/1675\/revisions"}],"predecessor-version":[{"id":1719,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/posts\/1675\/revisions\/1719"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/media\/1672"}],"wp:attachment":[{"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/media?parent=1675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/categories?post=1675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/macromillcnc.com\/wp-json\/wp\/v2\/tags?post=1675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}