Hello Guest it is October 17, 2019, 03:06:10 PM

Author Topic: need help with script  (Read 2227 times)

0 Members and 1 Guest are viewing this topic.

need help with script
« on: July 14, 2015, 07:22:48 AM »


i have this code in the signal script,

if (sig == mc.ISIG_INPUT1) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end

but what if i have two inputs

something like this  : 

 if ((sig == mc.ISIG_INPUT1) and (state == 1)) and ((sig == mc.ISIG_INPUT10) and (state == 1))
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end


how do i do that ?

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: need help with script
« Reply #1 on: July 14, 2015, 02:23:27 PM »
Code: [Select]
local Input1 = 0;
local Input10 = 0;
local hSig = 0;

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);
Input1 = mc.mcSignalGetState(hSig);

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10);
Input10 = mc.mcSignalGetState(hSig);

if (Input1 and Input10 and (state ==1)) then
    local inst = mc.mcGetInstance();
    mc.mcCntlCycleStart(inst);
end

--Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: need help with script
« Reply #2 on: July 15, 2015, 09:14:50 AM »
thank you its working :))
Re: need help with script
« Reply #3 on: July 15, 2015, 10:06:40 AM »
BTW , can i use this method in a sig table also ?

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: need help with script
« Reply #4 on: July 15, 2015, 05:02:30 PM »
yes but it`s a little bit different look in the mach 4 scripting manual it under manuals on mach web site
Re: need help with script
« Reply #5 on: August 31, 2015, 03:50:18 PM »
Found out that the piece of script from poppabear isn't working as intended. If you only activate one of either inputs the task wil already be executed.
the correct way to do this is.

local Input1 = 0;
local Input10 = 0;
local hSig = 0;

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);
Input1 = mc.mcSignalGetState(hSig);

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10);
Input10 = mc.mcSignalGetState(hSig);

if ((Input1 == 1) and (Input10 ==1)) then
    local inst = mc.mcGetInstance();
    mc.mcCntlCycleStart(inst);
end


I hope it is to some use.

Marco.
end