Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bill_O on February 26, 2019, 09:32:45 AM

Title: code problem
Post by: Bill_O on February 26, 2019, 09:32:45 AM
The attached code is giving me a nil value on the first line.
What do I have wrong.
Title: Re: code problem
Post by: RBeaubien on February 26, 2019, 10:22:35 AM
You didn't declare inst.  Try this:

local inst = mc.mcGetInstance()
local hreg=mc.mcRegGetHandle(inst, 'ESS/Encoder_0')
local EncRawVal=mc.mcRegGetValue(inst, hreg)
scr.SetProperty('droEncRep2', 'Value', tostring(EncRawVal))
Title: Re: code problem
Post by: Bill_O on February 26, 2019, 11:21:17 AM
Robert,

Thanks. I will give it a try.

Bill
Title: Re: code problem
Post by: Bill_O on February 26, 2019, 02:18:39 PM
When I run this code it crashes Mach4.
Title: Re: code problem
Post by: jbuehn on February 26, 2019, 02:48:55 PM
mc.mcRegGetValue only uses a single parameter...hreg
Title: Re: code problem
Post by: Bill_O on February 26, 2019, 03:12:17 PM
jbuehn,

Works perfect now.

Thanks,
Bill