Toggle state for newly created buttons?

If you have a question about the software please ask it here.

Toggle state for newly created buttons?

Postby chjade84 » Wed Sep 21, 2016 9:09 pm

We were discussing this on cnczone but I figured I'd move it over here since I'd rather have everything in one place over here. :D

So I've recreated a sidebar button on the main page to select a jog step of 0.01. Here are its properties:

http://imgur.com/a/3UZLh

I was told to add this to the screen script:
AS3.Switchbutton(bool State, int Buttonnumber);

Which I interpreted as

AS3.Switchbutton(bool true, int 164);

I put that in the .ssf file like so:

http://imgur.com/a/NwxOq

Now I just get a "Screen build error:defaultscreenset" error when I start the program. So I must have misunderstood something. :oops:
chjade84
 
Posts: 17
Joined: Wed Sep 21, 2016 4:46 pm

Re: Toggle state for newly created buttons?

Postby cncdrive » Wed Sep 21, 2016 9:32 pm

Your code has errors, because the int and bool are variable types definitions, you do not write them in function calls in any C based programming languages like C, C++ and C#, the syntax is different.
The type definitions are to be shown only in function prototypes when the programmer defines a function itself.
So, for example you define a function in a C# program like:

void Foo (int bar)
{
bar++;
}

Then you call this function with one integer parameter and because the return type is void you know the function does not return anything, so you call it like this:

Foo(1);

Another thing is that it is not a good idea to define anything manually in the Screenset file, because only the items and related definitions are what the software will remember when you will save the screenset from the editor, in other words it will not remember this kind of function which you have added, so as soon as you will make a screenset file save from the editor what you have added manually will dissapear.
To add things like switching a toggle button on startup you can add everything into the constructor macro M99998, that macro executes once always when you start the software.
The same way you can add things which you like to be executed on software closing into the M99999, that macro executes once always when the software is closing.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Toggle state for newly created buttons?

Postby chjade84 » Wed Sep 21, 2016 9:44 pm

Ah, so what code would I add to the M99998.txt file to have button 164 toggle state for on/off?
chjade84
 
Posts: 17
Joined: Wed Sep 21, 2016 4:46 pm

Re: Toggle state for newly created buttons?

Postby cncdrive » Wed Sep 21, 2016 11:52 pm

exec.Callbutton(164);

But that is the 0.01 units value for step jog and that is selected on startup, so I'm not sure why you want to call that?
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Toggle state for newly created buttons?

Postby chjade84 » Thu Sep 22, 2016 1:11 am

cncdrive wrote:exec.Callbutton(164);

But that is the 0.01 units value for step jog and that is selected on startup, so I'm not sure why you want to call that?


I want to have those buttons on the main run screen; I have tons of extra screen real estate and want the jog controls on the main screen with everything else. I tried just dragging them over, even changing the layer they are on but it seems there is no way to simply move the existing buttons from the side bar to the main screen; so I guess I have to re-create them.

I did successfully re-create the button on the main screen and it works just fine. It changes the jog mode to 0.01, however, it doesn't change state to show the little green light underneath to show it is active, or "true". I need to figure out how to re-create the image changing from unlit to lit when the button is pressed. When I click it, the original button in the side bar changes state and shows it is lit, however the graphic on the button I created remains unlit.
chjade84
 
Posts: 17
Joined: Wed Sep 21, 2016 4:46 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: Google [Bot] and 19 guests