Page 1 of 1

Runaway Ruby

Posted: Fri Nov 14, 2014 5:22 am
by JB_AU
I for some reason don't understand hot to use a trigger or boolean as input in ruby only when the trigger is fired or the boolean value changes & without them loading/firing when the schematic loads.

Code: Select all

require 'Win32API'
def system(cmd)
  sys = Win32API.new("crtdll", "system", ["P"], "L")
  sys.Call(cmd)
end

def system2(command)
  Win32API.new("crtdll","system",['P'],'L').Call(command)
end

#system("dir > c:\somefile.txt")
#system ('copy <c:\somefile.txt> <Brother DCP-165C Printer>')


A gentle kick pls

Re: Runaway Ruby

Posted: Fri Nov 14, 2014 5:52 am
by tulamide
That's what the event method is for.

Code: Select all

def event theInput, theValue
    #do react to theInput representing the bool or trigger
    #for example, if one input is named "mybool"
    if theInput == "mybool"
        #code in here when bool changed
    end
end

event will only be executed if triggered from outside, i.e. the value changes.

Re: Runaway Ruby

Posted: Fri Nov 14, 2014 6:19 am
by JB_AU
That make a lot of sense , thanks