Hello Guest it is April 13, 2021, 09:55:30 PM

Author Topic: Set propperties from button within a function  (Read 512 times)

0 Members and 1 Guest are viewing this topic.

Offline DAAD

  •  103 103
    • View Profile
Re: Set propperties from button within a function
« Reply #10 on: May 04, 2020, 12:58:03 AM »
I've got this code working from within a button at the moment.
If i click the button the state of the toggle is set propperly.
Now i want tho run it inside a macro so i can use it inside my M6 when i do a toolchange.
But then the code refuses to work. Nothing happens.

I thinks it's because this is a gui related code and the screen does not refresh when running a macro (or gcode file).

Is there a way i can refresh the screen to set this button when running a macro or gcode?

I tought of putting some script in the plc script, but because of the loop sequence, the button "flickers" when i trie to do that.

Keep Safe,


Code: [Select]
function zControl.ButtonState()
local axisID, mc.mcMotorGetAxis(inst,Spindle)
local h_OUTPUT4 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT4)
local state = mc.mcSignalGetState(h_OUTPUT4)

if ((axisID == mc.Z_AXIS) and (state == 1) then
scr.SetProperty('togRouterSpindle', 'Button State', (0))
                       scr.SetProperty('togRouterSpindle', 'Button State', (1)

Re: Set propperties from button within a function
« Reply #11 on: May 05, 2020, 03:27:09 AM »
You should learn to use the debugging features inside ZeroBrane to help identify reasons why code doesn't work

If its code from a module or screen load script I will normally copy the code and paste it into a script of temporary button that I created. First hit F7 to compile the code, this will highlight any initial errors in the Output window at the bottom.

After compilation is successful use F5 to start debugging and then F11 to step through the code line by line. You can right click on variables and add them to the Watch list so that you can see the values update as you step through the code. Any errors will be shown in the Output window at the bottom along with the line number that the error occurred on.