Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: wrecks on March 16, 2020, 11:12:07 AM

Title: Changing default state of toggle buttons
Post by: wrecks 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
Title: Re: Changing default state of toggle buttons
Post by: joeaverage 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
Title: Re: Changing default state of toggle buttons
Post by: joeaverage 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