Hello Guest it is March 28, 2024, 08:52:25 PM

Author Topic: Can i edit or add to a Predefined Macro?  (Read 5656 times)

0 Members and 1 Guest are viewing this topic.

Re: Can i edit or add to a Predefined Macro?
« Reply #10 on: January 26, 2017, 06:23:06 PM »
Hi smurph,
thanks for the explanation. What would happen if a cam program called m03.Does the leading zero get stripped in that
instance as well?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Can i edit or add to a Predefined Macro?
« Reply #11 on: January 26, 2017, 06:45:05 PM »
Hi,
just read thru (again) the mcSpindleSetDirection() doc.

I tried using the ENUM mc.MC_SPINDLDE_FWD and that works fine. I take it that using the ENUM is considered
better programming practice?

I notice also that the call has a return code.

I have coded:
local rc=mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_FWD)

I am not testing rc and so I made it local that it may be garbarge collected soonest.

I have at other times coded:
mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_FWD)

It works fine too but I'm unsure what happens to the return code, does it get ignored and therefore not
require garbage collection? Is there a preferred method for dealing with unspecified return values?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Can i edit or add to a Predefined Macro?
« Reply #12 on: January 26, 2017, 07:40:30 PM »
The G code interpreter will take M03, m03, M3, or m3 and turn them all into m3.  So when looking for a macro, it will use m3.  Much simpler than looking for all 4 variations.

Using the constants is a very good idea.  Because if we change the value of the constant, it will not require you to change your code.  :)

The return code is simply discarded and garbage collected if it is not used.  However, I strongly suggest checking for error codes!  Not only is it a good programming practice, it could have bearing on whether or not you loose a finger or not!  Yikes!  In truth, it is not necessary all of the time.  But if you get into the habit, it is going to pay dividends in the future for sure.

All of the API functions have their possible return codes documented and I'd say that the majority are correct.  In the event that we messed up, I prefer to test for inverse success.  e.g.

if (mc.mcSpindleSetDirection(inst, mc.MC_SPINDLE_FWD) ~= mc.MERROR_NOERROR) then
   --handle any failure!
end

Steve
Re: Can i edit or add to a Predefined Macro?
« Reply #13 on: January 26, 2017, 08:01:14 PM »
Hi Steve,
thanks for the explanation, something I seem to say to you a lot!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'