Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: tmax1 on January 01, 2019, 12:24:05 PM
-
Hello
I'm trying to find a script that will allow me to manually input Y coordinates and then go to that position. I dont want the MDI box, so I dont have to type "G0Y?" everytime
TIA
-
load a GCode file.
for example
G0X10
G0X20
G0X30
G0X30
G0X40
enable Single BLK
than you only have to hit Start for every single line
-
Thanks, but not exactly what i am looking for.
What i want to do is: click on a button, enter a value: ie. 23.625, hit enter and have the machine go to that position
-
ok then something like this might help:
Sub Main
Dim YPos As String
YPos = AskTextQuestion("Please enter Y Position (use . not , !): ")
If IsNumeric(YPos) Then
Code "G0Y"+CStr(YPos)
Message "driving Y to: " & YPos
Else
MsgBox "Vaule you entered is not numeric!"
End If
End Sub
-
TPS, THANK YOU!! that does exactly what I want...I am making a programmable stop for my cutoff say and this is going to work perfect....Thanks again!!
-
Can I ask 2 more questions, If I enter a value over 50 for Y, how can I have a message box say "value too high" And I have a virtual num pad that appears when the F9 key is pressed, is there a way to wmulate the F9 in a script so that the keypad comes up automatically
-
ok sorry for the delay,
first question no Problem, new code:
Sub Main
'declare variables
Dim YPos As String
Dim YMinPos As Double
Dim YMaxPos As Double
'preset the variables
YMinPos = 1.0
YMaxPos = 50.0
'show the input Box
YPos = AskTextQuestion("Please enter Y Position (use . not , !): ")
'check that the entered value is numeric
If IsNumeric(YPos) Then
'check the minimal value
If CDbl(YPos) < YMinPos Then
MsgBox ("entered value too low !")
Exit Sub
End If
'check the maximal value
If CDbl(YPos) > YMaxPos Then
MsgBox ("entered value too high !")
Exit Sub
End If
Code "G0Y"+CStr(YPos)
Message "driving Y to: " & YPos
Else
MsgBox "Vaule you entered is not numeric!"
End If
End Sub
second question:
And I have a virtual num pad that appears when the F9 key is pressed, is there a way to wmulate the F9 in a script so that the keypad comes up automatically
here i am not sure what would be the Trigger for "comming up" of the Keyboard (maybe the script, witch asks for the YPos?),
and how to trigge the Keyboard?
TPS
BTW:witch virtual Keyboard do you use? maybe i can choose a copy and test?
-
Thanks again!! I got the keyboard figured out
-
TPS
is there any way to duplicate the user input into a DRO?
-
hi,
here is a code sample witch uses DRO for strorage (to Display).
it uses a selfmade virtual Keyboard for numeric Input via touch Screen.
all values (min max DRONum) are adjustable in top aeria.
Global value As String
Sub Main
'declare variables
Dim YPos As Double
Dim OldDroValue As Double
Dim YMinPos As Double
Dim YMaxPos As Double
Dim DroNum As Integer
'preset the variables
YMinPos = 1.0
YMaxPos = 50.0
DroNum = 1201
'get the actual DRO value
OldDroValue = GetOemDro(DroNum)
'show the virtual keyboard
call NumericKeyboard(DroNum,YMinPos,YMaxPos)
'get the new DRO value
YPos = GetOEMDro(DroNum)
'check that the entered value has changed
If YPos <> OldDroValue Then
'doe the move
Code "G0Y"+CStr(YPos)
Message "driving Y to: " & YPos
End If
End Sub
'TPS 01.12.2017
'numerische Eingabe
Function NumericKeyboard(ByVal DRONum as Integer , ByVal Min as Double , ByVal Max as Double) As Double
Dim title as String
value = "" 'GetOemDRO(DRONum)
title = Header
Begin Dialog UserDialog1 60,60, 105, 210, "input value:" , .Enable
PushButton 10, 10, 25, 25, "7", .but7
PushButton 40, 10, 25, 25, "8", .but8
PushButton 70, 10, 25, 25, "9", .but9
PushButton 10, 40, 25, 25, "4", .but4
PushButton 40, 40, 25, 25, "5", .but5
PushButton 70, 40, 25, 25, "6", .but6
PushButton 10, 70, 25, 25, "1", .but1
PushButton 40, 70, 25, 25, "2", .but2
PushButton 70, 70, 25, 25, "3", .but3
PushButton 10, 100, 25, 25, ".", .butD
PushButton 40, 100, 25, 25, "0", .but0
PushButton 70, 100, 25, 25, "<-", .butB
PushButton 10, 130, 25, 25, "+/-", .butN
PushButton 40, 130, 25, 25, "Del", .butDel
TextBox 10, 160, 85, 18, .FText
PushButton 10, 185, 40, 21,"OK", .OK
CancelButton 55, 185, 40, 21
End Dialog
Dim Dlg1 As UserDialog1
Dlg1.FText = CStr(value)
x = Dialog( Dlg1 )
NumericKeyboard = CDbl(Dlg1.FText)
If CDbl(Dlg1.FText) < Min Then NumericKeyboard = Min
If CDbl(Dlg1.FText) > Max Then NumericKeyboard = Max
SetOEMDro(DRONum,NumericKeyboard)
End Function
Function Enable( ControlID$, Action%, SuppValue%)
Select Case Action%
Case 1
Case 2 'Button wurde gerückt
If ControlID$ = "but0" Then
value = CStr(value) + "0"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but1" Then
value = CStr(value) + "1"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but2" Then
value = CStr(value) + "2"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but3" Then
value = CStr(value) + "3"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but4" Then
value = CStr(value) + "4"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but5" Then
value = CStr(value) + "5"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but6" Then
value = CStr(value) + "6"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but7" Then
value = CStr(value) + "7"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but8" Then
value = CStr(value) + "8"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "but9" Then
value = CStr(value) + "9"
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "butD" Then
If InStr(1,value,".") = 0 Then
value = CStr(value) + "."
DlgText "FText", CStr(value)
Enable =1
End If
End If
If ControlID$ = "butB" Then
value = Left(value,Len(value)-1)
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "butN" Then
If Left(value,1) = "-" Then
value = "+" + CStr(Right(value,Len(value)-1))
Else
If Left(value,1) = "+" Then
value = "-" + CStr(Right(value,Len(value)-1))
Else
value = "-" + CStr(value)
End If
End If
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "butDel" Then
value = ""
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "OK" Then
Enable = -1
End If
Case 3 'Text verändert
'MsgBox Dlg1.FText
Case Else
End Select
'Wert zurückgeben
If Enable = -1 Then
Enable = value
End If
End Function
-
TPS
I am extremely impressed with your code writing ability....I can write some basic stuff, but this is awesome
Is there any way to make the number appear in the DRO as you are entering it, like it shows in the pop up num pad?
I will gladly share the screen set I am designing with you when I'm done.....
-
hi tmax1,
here the code with "online update" of the DRO during Input.
Global value As String
Global DroNum As Integer
Sub Main
'declare variables
Dim YPos As Double
Dim OldDroValue As Double
Dim YMinPos As Double
Dim YMaxPos As Double
'preset the variables
YMinPos = 1.0
YMaxPos = 50.0
DroNum = 1201
'get the actual DRO value
OldDroValue = GetOemDro(DroNum)
'show the virtual keyboard
call NumericKeyboard(DroNum,YMinPos,YMaxPos)
'get the new DRO value
YPos = GetOEMDro(DroNum)
'check that the entered value has changed
If YPos <> OldDroValue Then
'doe the move
Code "G0Y"+CStr(YPos)
Message "driving Y to: " & YPos
End If
End Sub
'TPS 01.12.2017
'numerische Eingabe
Function NumericKeyboard(ByVal DRONum as Integer , ByVal Min as Double , ByVal Max as Double) As Double
Dim title as String
value = "" 'GetOemDRO(DRONum)
title = Header
Begin Dialog UserDialog1 60,60, 105, 210, "input value:" , .Enable
PushButton 10, 10, 25, 25, "7", .but7
PushButton 40, 10, 25, 25, "8", .but8
PushButton 70, 10, 25, 25, "9", .but9
PushButton 10, 40, 25, 25, "4", .but4
PushButton 40, 40, 25, 25, "5", .but5
PushButton 70, 40, 25, 25, "6", .but6
PushButton 10, 70, 25, 25, "1", .but1
PushButton 40, 70, 25, 25, "2", .but2
PushButton 70, 70, 25, 25, "3", .but3
PushButton 10, 100, 25, 25, ".", .butD
PushButton 40, 100, 25, 25, "0", .but0
PushButton 70, 100, 25, 25, "<-", .butB
PushButton 10, 130, 25, 25, "+/-", .butN
PushButton 40, 130, 25, 25, "Del", .butDel
TextBox 10, 160, 85, 18, .FText
PushButton 10, 185, 40, 21,"OK", .OK
CancelButton 55, 185, 40, 21
End Dialog
Dim Dlg1 As UserDialog1
Dlg1.FText = CStr(value)
x = Dialog( Dlg1 )
NumericKeyboard = CDbl(Dlg1.FText)
If CDbl(Dlg1.FText) < Min Then NumericKeyboard = Min
If CDbl(Dlg1.FText) > Max Then NumericKeyboard = Max
SetOEMDro(DRONum,NumericKeyboard)
End Function
Function Enable( ControlID$, Action%, SuppValue%)
Select Case Action%
Case 1
Case 2 'Button wurde gerückt
If ControlID$ = "but0" Then
value = CStr(value) + "0"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but1" Then
value = CStr(value) + "1"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but2" Then
value = CStr(value) + "2"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but3" Then
value = CStr(value) + "3"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but4" Then
value = CStr(value) + "4"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but5" Then
value = CStr(value) + "5"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but6" Then
value = CStr(value) + "6"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but7" Then
value = CStr(value) + "7"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but8" Then
value = CStr(value) + "8"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "but9" Then
value = CStr(value) + "9"
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "butD" Then
If InStr(1,value,".") = 0 Then
value = CStr(value) + "."
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
End If
If ControlID$ = "butB" Then
value = Left(value,Len(value)-1)
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "butN" Then
If Left(value,1) = "-" Then
value = "+" + CStr(Right(value,Len(value)-1))
Else
If Left(value,1) = "+" Then
value = "-" + CStr(Right(value,Len(value)-1))
Else
value = "-" + CStr(value)
End If
End If
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "butDel" Then
value = ""
DlgText "FText", CStr(value)
SetOEMDro(DRONum,CDbl(value))
Enable =1
End If
If ControlID$ = "OK" Then
Enable = -1
End If
Case 3 'Text verändert
'MsgBox Dlg1.FText
Case Else
End Select
'Wert zurückgeben
If Enable = -1 Then
Enable = value
End If
End Function
-
Works Perfect, thank you so much!