Hello Guest it is April 25, 2024, 07:37:29 AM

Author Topic: How to show the value of a variable in the ZeroBrane Editor?  (Read 2832 times)

0 Members and 1 Guest are viewing this topic.

Offline jevs

*
  •  315 315
    • View Profile
How to show the value of a variable in the ZeroBrane Editor?
« on: August 04, 2019, 01:41:33 PM »
I am watching a video on youtube and he is hovering over things and getting values in the editor. This does not seem to work in the current editor?
Is there a way to see this?
I can right click stuff and select "Evaluate in console", but all i ever get is nil.
I am not really sure how your supposed to test your code to see if it is working without getting it all done and seeing if it runs in Mach4 or not. It would be nice if you could run it and get some idea of what you have written so far is working.
Keep in mind I am not a computer programmer.
« Last Edit: August 04, 2019, 01:45:50 PM by jevs »
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #1 on: August 04, 2019, 01:55:45 PM »
Hi,
hovering over the variable works......if it shows nil then the variable has no defined value.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline jevs

*
  •  315 315
    • View Profile
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #2 on: August 04, 2019, 02:08:54 PM »
I must be doing something wrong because I get nil for everything.
Code: [Select]
function m6()

local inst = mc.mcGetInstance()
local selectedTool = mc.mcToolGetSelected(inst) --Gets selected tool
selectedTool = math.tointeger(selectedTool) --Converts selected tool to integer
local currentTool = mc.mcToolGetCurrent(inst) --Gets currently loaded tool
currentTool = math.tointeger(currentTool) --Converts currenlty loaded tool to integer

Shouldn't I be able to get a value at least for the current tool? It has a current tool on the screen. Somehow I think the editor and mach are not in communication at this point.
I never get any values by hovering over anything in the screen load script or anywhere else either and selecting evaluate in console give nil on everything.
So, I am not sure what I have wrong.

About from the editor:
ZeroBrane Studio (devel; MobDebug 0.702)
Copyright © 2011-2017 ZeroBrane LLC
Paul Kulchenko
Licensed under the MIT License.
Based on Estrela Editor
Copyright © 2008-2011 Luxinia DevTeam
Christoph Kubisch, Eike Decker
Licensed under the MIT License.

Based on wxLua editor
Copyright © 2002-2005 Lomtick Software
J. Winwood, John Labenski
Licensed under wxWindows Library License, v3.
Built with wxWidgets 3.1.1, wxLua 2.8.12.3
« Last Edit: August 04, 2019, 02:14:11 PM by jevs »
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #3 on: August 04, 2019, 02:11:58 PM »
Hi,
you will get a value once the line has been executed.....until it has the variable is undefined.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #4 on: August 04, 2019, 02:24:54 PM »
Hi,
you only get live data when you are in a de-bug session.....you do have the debugger running when trying
to get live values?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline jevs

*
  •  315 315
    • View Profile
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #5 on: August 04, 2019, 02:50:48 PM »
I think I am starting to figure this out....I wish there was a video tutorial though.
I cannot get the debugger to run on my stuff. I just get an error.

However, I loaded up a lua example from the mach4 directory to try to figure out how it works.
I guess I need to put a red ball everywhere I want the debugger to stop and then F5 moves it to the next red ball. Then I can hover over things and get a value.

If you start the debugger (green arrow) then it ends up putting a green arrow next to the first line that is not a comment. Nothing in there has a value. If you hit the green arrow again, it just seems to exit the debugger. So, I assume you have to put a red ball on the lines to make it stop without exiting? It will not stop on every line though, so I guess it can only stop at certain places in the code depending on what the code is.

Offline jevs

*
  •  315 315
    • View Profile
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #6 on: August 04, 2019, 02:58:09 PM »
I still get nil where I think there should be a value....not sure. I am learning a little here by trial and error though (which is not the fastest way) :)

I commented out my bad code that was stopping the debugger from loading and running. I wish they would give the exact way to do things in the API help instead of giving you a basic idea that you have to figure out what to add or change to make it work....

Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #7 on: August 04, 2019, 02:58:51 PM »
Hi,

Quote
If you start the debugger (green arrow) then it ends up putting a green arrow next to the first line that is not a comment. Nothing in there has a value.

The green arrow shows that this is the next instruction to be executed, it has not been executed yet and so the variable may well
be undefined. What you need to do is single-step through the code, that is DON'T push the green arrow again but F11.
Once the line has been executed then hover on the variable.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline jevs

*
  •  315 315
    • View Profile
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #8 on: August 04, 2019, 03:01:42 PM »
Hi,

Quote
If you start the debugger (green arrow) then it ends up putting a green arrow next to the first line that is not a comment. Nothing in there has a value.

The green arrow shows that this is the next instruction to be executed, it has not been executed yet and so the variable may well
be undefined. What you need to do is single-step through the code, that is DON'T push the green arrow again but F11.
Once the line has been executed then hover on the variable.

Craig

Ahh, that helps. I figured there should be a way to step through one line at a time without adding a bunch of red balls which still skips stuff.....thanks.
You can see where a tutorial video would help someone that knows so little :)

Do you know where I might find an M6 for an ATC with a tool height touch plate? If I could see some code rather than trying to reinvent it from scratch it would be much faster. I am doing stuff now that I do not know if it is even needed. Just trying to mimic my old VB script from Mach3, but I did not have a touch plate to set tool heights then. Part of why I am switching to mach4 is so I can have more than one probe input (3D and tool height) without trying to put them in series on the same input. This is not as nice because then you have to short the input jack on the 3d probe or the touch plate won't work when it is detached (NC probes).
« Last Edit: August 04, 2019, 03:07:00 PM by jevs »

Offline jevs

*
  •  315 315
    • View Profile
Re: How to show the value of a variable in the ZeroBrane Editor?
« Reply #9 on: August 04, 2019, 03:11:13 PM »
This is already a big help! Now I got one thing working. Using the debugger is so much faster...