Cmd operator

The <Cmd> operator provides a flexible mechanism for working with the current CLData command. It returns a reference to the current command, on which you can request a code, name and parameters of this command. Format of access to specific command data following.


<Cmd.Code> - returns a unique numeric code of the CLData command. Each command is uniquely identified by this code. List of command codes listed in the appendicies.


<Cmd.Name> - returns the text name of the command or command parameter.


<Cmd.Data> - for individual CLData commands, which have a single string parameter (such as Comment, PartNo, etc.), returns string value. For the rest of the commands returns a string representation of the command, exactly what is displayed on the tab CLData of main window.


<Cmd.Data[Index]> - an alternative way to access an array of numeric parameters of command CLD. Returns the real value of the parameters array element with the index Index.


The following below are a few language structures allow access to the parameters of CLData command by parameter name. See Named CLData parameters topic for more information. Each CLData command can be characterized by its own set of named parameters. The names of the parameters with description for each command are listed in the appendicies. The parameter names can be seen on CLData tab at the bottom of the main window.


<Cmd.Str["ParameterName"]> - returns the value of the command parameter with the name ParameterName as a text String.


<Cmd.Int["ParameterName"]> - returns the value of the command parameter with the name ParameterName as an Integer number.


<Cmd.Flt["ParameterName"]> - returns the value of the command parameter with the name ParameterName as a Real number (floating point number).


<Cmd.Ptr["ParameterName"]> - returns a reference to the command parameter with the ParameterName name.



Consider a few examples of CLData command parameters using.



Example 1. Inside the tool loading command handler LoadTl to NC-program output the string with address T, with number of the tool and with the name of the turret head in parentheses.



program LoadTl
  Output "T" + Cmd.Int["ToolID"] + "(" + Cmd.Str["RevolverID"] + ")"
end


A possible result of the output to the NC-code: T3 (TopTurret)



Example 2. Example of MultiGoto command processing using various methods to access elements of array parameter Axes.



program MultiGoto
  i: Integer
  AxisName: String
  
  for i = 1 to Cmd.Ptr["Axes"].ItemCount do begin
    AxisName = cmd.Ptr["Axes"].Item[i].Str["AxisID"]
    if AxisName="AxisXPos" then begin
      X = cmd.Ptr["Axes"].Item[i].Flt["Value"]
    end else
    if AxisName="AxisYPos" then begin
      Y = cmd.Ptr["Axes("+Str(i)+")"].Flt["Value"]
    end else
    if AxisName="AxisZPos" then begin
      Z = cmd.Flt["Axes("+Str(i)+").Value"]
    end else
    if cmd.Ptr["Axes(AxisCPos)"]<>0 then begin
      C = cmd.Flt["Axes(AxisCPos).Value"]
    end
  end
  OutBlock
end



Example 3. Example of coordinate system setup command processing Origin. It analyzes the <OriginType> property's value . If it is zero, output the standard workpiece coordinate system selection command G54-G59. Number of the coordinate system is taken from the parameter <CSNumber>. Otherwise the local coordinate system transfer command G92 X Y Z is formed . The values of the displacements along the axes of the coordinate system are taken in different ways from the corresponding child properties of the <MCS.OriginPoint> parameter.



program Origin
  if Cmd.Int["OriginType"]=0 then begin !G54-G59
    Output "G" + Cmd.Str["CSNumber"]
  end else begin                        !G92 X Y Z
    X = Cmd.Flt["MCS.OriginPoint.X"]
    Y = Cmd.Ptr["MCS.OriginPoint.Y"].Flt
    Z = Cmd.Ptr["MCS.OriginPoint"].Flt["Z"]
    Output "G92 X" + Str(X) + " Y" + Str(Y) + " Z" + Str(Z)
  end
end



See also:

CLData functions and operators