Hello Guest it is May 14, 2021, 10:16:21 PM

Author Topic: Changing default state of toggle buttons  (Read 314 times)

0 Members and 1 Guest are viewing this topic.

Changing default state of toggle buttons
« on: March 16, 2020, 11:12:07 AM »
I have found this snippet of code in screenscript.lua

    -------------------------------------------------------
    --  PLC First Run
    -------------------------------------------------------
    if (testcount == 1) then --Set Keyboard input startup state
        local iReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
        mc.mcIoSetState(iReg, 1) --Set register to 1 to ensure KeyboardInputsToggle function will do a disable.
        KeyboardInputsToggle()
       
        --scr.SetProperty('btnCycleStart', 'Label', 'Cycle Start\nGcode')
        prb.LoadSettings()

The snippet is in function Mach_PLC_Script()
   
 I want to change this to make Keyboard/Enable enabled on startup instead of disabled.

I know how to write the code, but I can't figure out how to open an editor that contains the code. How do I edit Mach_PLC_Script? i have tried very hard to figure this out myself, but I give up.

I am using Mach 4
« Last Edit: March 16, 2020, 11:19:05 AM by wrecks »
Re: Changing default state of toggle buttons
« Reply #1 on: March 19, 2020, 07:11:11 PM »
Hi,
this post is best placed in the Mach4 General Discussion board, it would receive more views from Mach4 users.
I am at work at the moment but when I get home tonight I will post a series of screenshots as to how to get the PLC script open in the editor.
When I show you you how simple it is your'e going to curse yourself for not finding it for yourself.

Craig
My wife left with my best friend...
     and I miss him!
Re: Changing default state of toggle buttons
« Reply #2 on: March 20, 2020, 03:48:02 PM »
Hi,
got home, had something to eat, sat down.....and suddenly its the next day....I fell asleep!

As promised:
Close any Gcode that is running. Disable Mach4. Click the Operator Tab and select Edit Screen.
In the Screen Tree Manager double click the topmost item, it will be your profile name, in my example 'ESSMillwx4'.
Click the Events button in the Properties panel and viola there are the major scripts that form Mach, including the PLC
script. Click on the script and it will open in the Zero Brane editor.

Be sure to properly close the editor and save your edits, having one of these scripts open when it should in fact be closed,
ie after you have finished with it will crash Mach.

Craig
My wife left with my best friend...
     and I miss him!