Hello Guest it is March 28, 2024, 06:16:20 AM

Author Topic: Get screen propety on macro  (Read 540 times)

0 Members and 1 Guest are viewing this topic.

Get screen propety on macro
« on: August 09, 2021, 05:22:18 AM »


Hello,

I have a macro ex: "m200" , I need get some screen propeties like a label or textbox etc.



This only get value inside a screen (plc or Screen Load script etc), not work on macro.
local ex= scr.rtGetProperty('myPropety','Value')



I find this code and if included on my macro work.
scr = require("screenipc)
scr.scIpcInit('127.0.0.1")


The problem is , when this macro runs while gcode is running , the macro gets blocked and gcode stops running.

Any solution?

Thanks







Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Get screen propety on macro
« Reply #1 on: August 15, 2021, 04:16:49 PM »
Just calling

scr = require("screenipc")
scr.scIpcInit("127.0.0.1")

makes the macro stop? 

Check your syntax. your original require didn't have a " and the scIpcInit() had a ' at the beginning of 127.0.0.1 and a " at the end. 

Next, you really don't want to "require" every time you run the M code macro.  Make a file in the macros directory called "screenipc.mcs" and put:

scr = require("screenipc")
scr.scIpcInit("127.0.0.1")

in it.  This will cause a file named screenipc.mcc to be built the next time you hit cycle start.  The "scr" library prefix will then be available to all M code script in the macro directory.  Meaning all you would have to do in your m200 macro is call scr.rtGetProperty('myPropety','Value').  Please do check the return codes of the function for errors, as all mysteries will cease to be and it is just good programming practice to do so.