<!doctypehtml><meta content="text/html; charset=utf-8"http-equiv=Content-Type><meta content="Adobe RoboHelp 2019"name=generator><title>
   Using Expressions for Commanded Axes
  </title><link href=../../default.css rel=StyleSheet><script language=JavaScript>//<![CDATA[
<!-- Begin
var showAllFlag = 1;

function swapShowHide() { 

        if (showAllFlag == 1){
                imageShowAll.src = "HideAll.gif";
                showAllFlag = 0;
                JavaScript:showEm()
        }else{
                imageShowAll.src = "ShowAll.gif";
                showAllFlag = 1;
                JavaScript:hideEm()
        } 
} 
//  End -->
//]]></script><script language=JavaScript1.2>//<![CDATA[
<!--
var arrayofDivs = document.getElementsByTagName("DIV");
function showEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = ""; }
} 
function hideEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "none"; }
} 
//-->
//]]></script><script language=JavaScript>//<![CDATA[
function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight)
     location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
	origWidth = innerWidth;
	origHeight = innerHeight;
	onresize = reDo;
}
onerror = null; 
//]]></script><style><!--
div.WebHelpPopupMenu { position:absolute;
left:0px;
top:0px;
z-index:4;
visibility:hidden; }
p.WebHelpNavBar { text-align:right; }
--></style><script src=../../template/scripts/rh.min.js></script><script src=../../template/scripts/common.min.js></script><script src=../../template/scripts/topic.min.js></script><script src=../../template/scripts/constants.js></script><script src=../../template/scripts/utils.js></script><script src=../../template/scripts/mhutils.js></script><script src=../../template/scripts/mhlang.js></script><script src=../../template/scripts/mhver.js></script><script src=../../template/scripts/settings.js></script><script src=../../template/scripts/XmlJsReader.js></script><script src=../../template/scripts/loadparentdata.js></script><script src=../../template/scripts/loadscreen.js></script><script src=../../template/scripts/loadprojdata.js></script><script src=../../template/scripts/mhtopic.js></script><link href=../../template/styles/widgets.min.css rel=stylesheet><link href=../../template/styles/topic.min.css rel=stylesheet><script>gRootRelPath = "../..";
gCommonRootRelPath = "../..";
gTopicId = "5.1.0_8";</script><meta content="Programming > User Programs"name=topic-breadcrumbs><body><script src=../../ehlpdhtm.js></script><h1>Using Expressions for Commanded Axes</h1><p class=NormalWithSpacing>This topic describes the <span style="font-weight: bold;"> Use Expressions </span> option in the <span style="font-weight: bold;"> Commanded Axes </span> list in user program commands. This allows the commanded axes to be programmatically selected when the user program is running. This feature is useful for machines that occasionally may need to disable an axis but yet run the user programs that normally send commands those axes.<p class=NormalWithSpacing>This is an advanced feature that will not typically be used in most applications.<p class=TopicHead2>Overview<p class=DescriptionBody>The <span style="font-weight: bold;"> Use Expression </span> option provides an <a href=../Expressions/Expressions_Overview.htm> expression </a> box to provide a mask for selecting the commanded axes. The expression must evaluate to a DWORD. The bits in the DWORD correspond to the axis number. If the bit is set, the command will be sent to the corresponding axis. If the no bits are set, the command will not be sent to any axis. Any bits set for which no axis exists will be ignored.<p class=TopicHead2>Example 1: Single Command to Multiple Axes<p class=DescriptionBody>This example demonstrates how to send a single command to any axes as set by a variable.<p class=DescriptionBody> <ol style="list-style: lower-alpha;"><li style="list-style: decimal;"><p class=DescriptionBody><span style="font-weight: bold;"> MyMask </span> is as a DWORD variable in the Variable Table.</p><li style="list-style: decimal;"><p class=DescriptionBody>This user program sends a Move Absolute (20) command to the axes defined by the bits set in the MyMask variable: <br> <br> <img style="border:none; width:100%; max-width:787px;"alt border=0 src=UserProgUseExprEx1.png> <br></p><li style="list-style: decimal;"><p class=DescriptionBody>When the user program runs, if bits 0, 1, and 3 are set, then the command will be sent to Axis 0, Axis 1, and Axis 3.</p></ol><p class=TopicHead2>Example 2: One Command to Each Axis<p class=DescriptionBody>This example demonstrates one method of programmatically removing one or more axes when sending a set of commands to a set of axes.<ol style="list-style: lower-alpha;"><li style="list-style: decimal;"><p class=DescriptionBody>The following variables are defined:</p> <ol style="list-style: lower-alpha;"><li><p class=DescriptionBody><span style="font-weight: bold;"> ActiveAxes: </span> A DWORD that will be define which axes should receive commands.</p><li><p class=DescriptionBody><span style="font-weight: bold;"> Axis1Mask, Axis2Mask, Axis3Mask, Axis4Mask: </span> DWORD variables that will be used as constants. Each of these variables is initialized to a value that has the bit set for its respective axis. The values of these variables must always remain the same.</p></ol><li style="list-style: decimal;"><p class=DescriptionBody>This user program step has one Move Absolute (20) command for each axis. Since the <span style="font-weight: bold;"> ActiveAxes </span> variable is ANDed with the axis-specific <span style="font-weight: bold;"> Axis </span> <span style="font-style: italic; font-weight: bold;"> n </span> <span style="font-weight: bold;"> Mask </span> variable, each command can only be sent to the axis specified by the respective <span style="font-weight: bold;"> Axis </span> <span style="font-style: italic; font-weight: bold;"> n </span> <span style="font-weight: bold;"> Mask </span> variable, and only if the respective bit in the <span style="font-weight: bold;"> ActiveAxes </span> variable is set. <br> <br> <img style="border:none; width:100%; max-width:795px;"alt border=0 src=UserProgUseExprEx2.png> <br></p><li style="list-style: decimal;"><p class=DescriptionBody>The <span style="font-weight: bold;"> Wait For </span> Link Condition waits for the In Position bit to turn on for only the selected axes. The expression is too long to be viewed from the Link Condition box, but is shown above in the tooltip window.</p></ol><p class=TopicHead2> <p style="font-weight: bold;"class=NormalWithSpacing><span style="font-weight: bold;"> See Also </span><p class=DescriptionBody><a href=User_Programs_Creating.htm> Creating User Programs </a> | <a href=../Expressions/Expressions_Overview.htm> Expressions Overview </a><hr style="margin-left: 25px;"align=left width=90%><p class=DescriptionBody><script style="x-condition: Online; x-condition: Online; x-condition: Online;"language=JavaScript1.2>//<![CDATA[
var sStart;
var sMiddle;
var sEnd;
var sFilename;
var sLocation;

sStart = "<a href='mailto:helpfeedback@deltamotion.com?subject=RMCTools%20Help%20Feedback.%20Topic:%20";

sLocation = window.location.href;

if (sLocation.lastIndexOf("::") != -1) 
{ 
        sLocation = sLocation.substring(sLocation.lastIndexOf("::")+2); 
} 

sMiddle = sLocation;



sEnd = "'> Send comments on this topic.<\/a>";

document.write(sStart + sMiddle + sEnd);
//]]></script><div><p class=DescriptionBody>Copyright (c) 2005-2020 by Delta Computer Systems, Inc.</div><div style="width: 100%; position: relative;"id=footer><script async src=https://www.googletagmanager.com/gtag/js?id=UA-304986-2></script><script>window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-304986-2');</script></div>