Hello Guest it is March 29, 2024, 02:05:34 AM

Author Topic: code problem  (Read 854 times)

0 Members and 1 Guest are viewing this topic.

Offline Bill_O

*
  •  563 563
    • View Profile
code problem
« on: February 26, 2019, 10:32:45 AM »
The attached code is giving me a nil value on the first line.
What do I have wrong.
Re: code problem
« Reply #1 on: February 26, 2019, 11: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))
- Robert Beaubien
- Drone Plastics
-
“Dear Algebra, Please stop asking us to find your X.  She's never coming back and don't ask Y.”

Offline Bill_O

*
  •  563 563
    • View Profile
Re: code problem
« Reply #2 on: February 26, 2019, 12:21:17 PM »
Robert,

Thanks. I will give it a try.

Bill

Offline Bill_O

*
  •  563 563
    • View Profile
Re: code problem
« Reply #3 on: February 26, 2019, 03:18:39 PM »
When I run this code it crashes Mach4.

Offline jbuehn

*
  •  101 101
    • View Profile
Re: code problem
« Reply #4 on: February 26, 2019, 03:48:55 PM »
mc.mcRegGetValue only uses a single parameter...hreg
« Last Edit: February 26, 2019, 03:55:19 PM by jbuehn »

Offline Bill_O

*
  •  563 563
    • View Profile
Re: code problem
« Reply #5 on: February 26, 2019, 04:12:17 PM »
jbuehn,

Works perfect now.

Thanks,
Bill