G-Wizard Calculator:
Fast, Easy, Reliable Feeds and Speeds


Join 100,000+ CNC'ers!  Get our latest blog posts delivered straight to your email inbox once a week for free. Plus, we’ll give you access to some great CNC reference materials including:

  • Our Big List of over 200 CNC Tips and Techniques
  • Our Free GCode Programming Basics Course
  • And more!


GCode is Complicated
G-Wizard Makes it Easy

How to change Y value in a subroutine?


I am trying to write a subroutine that has all the codes neccessary for a specific variable that I want. So if in the main program I want the Y value to be 29 how would I insert a subroutine so that when I insert 29 it will automatically change to 29 for the Y value in the subroutine ?

  • You must to post comments
Best Answer

Henry, if I understand your question, there are a couple of ways.  One would be to simply have “29” be in the Y before calling the subroutine.  The other answers depend on your controller.  With a Fanuc, you can pass in the Y on the same line and it comes out in a #variable that can be accessed.  You could also assign the Y value to a particular #variable and then reassign back to Y in the subroutine.

For more on subroutines and #variables, check out our free G-Code Tutorial:

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Show us your humanity*


Do you want to be a better CNC'er in 37 Seconds?

Get Better Tool Life, Surface Finish, and Material Removal Rates Fast.

It's that easy. You can install and get results in a matter of minutes.


Start Now, It's Free!



  GW Calculator

  GW Editor



  Deals and Steals

CNC Blog








     Feeds and Speeds

     G-Code Tutorial

     CNC Machining & Manufacturing

     DIY CNC Cookbook

     CNC Dictionary

CNC Projects


     Machinist's Search


     Online Groups


     Reference Data


     CNC Dictionary


     Tool Brands


     Hall of Fame

     Organization: Soon!





     Our History

     Privacy Policy

All material © 2016, CNCCookbook, Inc.