Hello Guest it is March 19, 2024, 07:14:48 AM

Author Topic: How do you read User Fields in the Tool Table?  (Read 871 times)

0 Members and 1 Guest are viewing this topic.

How do you read User Fields in the Tool Table?
« on: December 21, 2018, 10:32:15 PM »
I'm trying to read a custom user field that I'm putting in a tool table. 
I want to add the field "Heavy Tool" to the tool table.  I've got it set up but I don't know the syntax to read it from the m6.
 
Going back to my Hurco code, I am reading the Pocket from the tool table, here is that line of code:
local Pocket = mc.mcToolGetData(inst, mc.MTOOL_MILL_POCKET, Tool);

I named my user field "Heavy" to keep it simple for now and tried this code and it did not work...:
local HeavyToolCheck = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEAVY, Tool);

When you set the user field up it asks for a Key Name input, So I made it "Heavy"  I figured that would be what I put in the macro, but it isn't.
Anyone know how to do this?
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: How do you read User Fields in the Tool Table?
« Reply #1 on: December 21, 2018, 11:14:54 PM »
Depends on what kind of data is in the custom field you created. A integer, double or string. Looking at the API doc I think it would be this one for a double ........

value, rc = mc.mcToolGetDataExDbl(number mInst, number toolNumber, string fieldName) --This is the explanation of the 3 parameters from the doc

The API call should make you think....... mc.mc Tool Get Data Extended as a double

value, rc = mc.mcToolGetDataExDbl(inst, 2, "Heavy") --This is how it might look in actual use.

Then the 3 parameters are

inst = instance and the manual says its expecting a type number for this parameter
2 = Tool number and its expecting a type number for this parameter
"Heavy" = field Name and it is expecting a type string for this parameter ("" make it a string). 0 = number "0" = string
« Last Edit: December 21, 2018, 11:21:25 PM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: How do you read User Fields in the Tool Table?
« Reply #2 on: December 21, 2018, 11:41:20 PM »
That did it, works like a charm!
I didn't think of using the another type of tool get data.
Thanks!
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: How do you read User Fields in the Tool Table?
« Reply #3 on: December 22, 2018, 10:13:49 AM »
 :)
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!