Hello Guest it is April 28, 2024, 12:18:53 PM

Author Topic: Read a value and execute a User-Macro  (Read 927 times)

0 Members and 1 Guest are viewing this topic.

Read a value and execute a User-Macro
« on: September 11, 2023, 07:59:13 AM »
Hello

I'm optimizing my Screenset.
The Basis of my Sreenset is from PA.
But I did so many imprvements and Errorcorections.

Now I try to build a button where set the x-coordinate an then the Spindle goes to this coordinate.
Simply: Goto X Goto Y Goto Z

Im try to do this with machsreen.

My question is:
How can I build a Button that reads the valeu and then executes a VB-Script where i can Use the value?
I only find something where I can define the Value and something where I can execute Code.But I need a Button whitch is dooing both!


Thanks a lot
« Last Edit: September 11, 2023, 08:02:46 AM by Kissling »

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Read a value and execute a User-Macro
« Reply #1 on: September 11, 2023, 08:03:54 AM »
you can use a Button Standard code 34 -> run basic script

then you can program your own VB-Script within this button.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Read a value and execute a User-Macro
« Reply #2 on: September 11, 2023, 08:56:05 AM »
Thanks to TPS

But than I have to Insert 2 thinks.

one to write the  value
and
as you wrote
one for executing the script

I there no way to way to get this:
write the value in the feeld
by pressing Enter the macro is executed

Regards

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Read a value and execute a User-Macro
« Reply #3 on: September 11, 2023, 09:03:40 AM »
[1] first select function - execute basic script
[2] doubleclick execute Code value, then editor for basic script is comming up
and now you can proramm your basic code to enter the value and execute G-code
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Read a value and execute a User-Macro
« Reply #4 on: September 11, 2023, 11:13:07 AM »
Hello TPS,

this is all no problem!

My Problem is:
How can i execute the basic Sript when I write a new value to the UserDRO?

Do I have to design a UserDRO AND a Button?

Regards

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Read a value and execute a User-Macro
« Reply #5 on: September 11, 2023, 12:56:03 PM »
put a transparent button above the DRO

this is just a simple example how you can do it:

Code: [Select]

Dim DROValue As String
DROValue = AskTextQuestion("Please enter new Value:")
SetOEMDRO(800,CDbl(DROValue))
Message "Hello you entered , " & DROValue & " into DRO800!"


if you do a search for "simple numeric keyboard" you will find a code snipped i have posted years ago witch is an
other solution
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Read a value and execute a User-Macro
« Reply #6 on: September 13, 2023, 09:25:36 AM »
Thanks a lot for this solution.

Works well.

But I try to find a solution where no "AskTextQuestion" is used to enter the value.

I try to  find a way where i can write the value in the DRO-Feld and the macro is executed when pressing Enter

Maybe there is another way?

Grüße aus Bayern nach Bayern :-)

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Read a value and execute a User-Macro
« Reply #7 on: September 15, 2023, 02:21:40 AM »
there is no "direct" way to do this, because the is no "event driven" input possibility for screen's.
a work arround would be to use the macropump macro, with is running as a background task, do
do this.

example:
-use in screenset OEMDro(1300) to change a value
-in macropump check OEMDro(1300) cyclic and if it has changed exceute code

example for macropump code:
Code: [Select]
'check OEMDro(1300) for change
If (GetOEMDro(1300)<>GetOEMDro(1301)) Then
  'put here the code witch should be exceuted
  Message "i was here"
End If
'save OEMDro(1300) for next cyclic change
SetOEMDro(1301,GetOEMDro(1300))

Gruß Tom.
Ich schreibe das hier in Englisch, nun ja in meinen bayrischen Englisch,
das es für die Anderen lesbar bleibt.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.