831
Machscreen Screen Designer / Re: Estimate(815)/Elasped(814) dro different
« on: March 11, 2013, 11:37:50 AM »
Glad you're sorted.
Ian
Ian
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
If getUserLED (1012) Then 'if LED is ON we'll treat that as meaning the DRO is currently inches
setUserDRO(1010 , GetUserDRO(1010) * 25.4) 'so change it to mm
setUserLed(1012,0) 'set LED OFF which means the value now means mm
Else 'LED is OFF which we treat as meaning the DRO is currently mm
setUserDRO(1010 , GetUserDRO(1010) / 25.4) 'so change the value to inches
setUserLed(1012,1) 'set LED ON which means the value now means inches
End If
was hoping to be able to enter a number(say 12) and then click
my button to change it to inch or mm. that's it. just a simple
convertion button.
Option Explicit
'define the strings we're looking for - add/change as you see fit
Dim needles(2) As String
needles(0)="M6"
needles(1)="M06"
needles(2)="M 6"
Dim currentLine As Integer
Dim thisLine As Integer
Dim fileSys As Object
Dim fileTxt As Object
Dim haystack As String
Dim needle As String
Dim matchFound As Boolean
Const forReading = 1
currentLine = GetOEMDRO(816) 'note where Mach currently is in the gcode file
matchFound = False
'open the file in cb
Set fileSys = CreateObject("scripting.fileSystemObject")
Set fileTxt = fileSys.openTextFile(fileName, forReading, true)
'no point in reading all the lines we're already past so skip 'em
For thisLine = 0 To currentLine - 1
fileTxt.skipLine
Next
thisLine = thisLine - 1
'plough through the rest of the file looking for our needles in the haystack
'we'll either get to the end or we'll find our match
While Not fileTxt.atEndOfStream And Not matchFound
haystack = UCase(fileTxt.readLine()) 'get the whole line
If haystack <> "" Then 'check it's not empty if it is just skip it
thisLine = thisLine + 1
For Each needle In needles 'look through the line for our required strings
If InStr(haystack, needle) Then
SetOEMDRO 816,thisLine
matchFound = true
Exit For 'no point in checking the rest of the line
End If
Next
End If
Wend
If matchFound Then
MsgBox "File has been set to line:" & thisLine & _
"your Next toolchange position." & Chr(13) & Chr(10) & _
"Your previous line was:" & currentLine
Else
Dim msg As String
For Each needle In needles
msg=msg & needle & " "
Next
MsgBox "No " & msg & " found after line:" & currentLine
End If
fileTxt.Close
Set fileSys = Nothing
Set fileTxt = Nothing
my teacher wants us to experiment on vbscipt but i dont have any idea...
DoOEMButton(106) 'toggle system units
InchMM = GetUserDRO(1010) 'get whatever
If GetOEMLED (802) Then 'if the system is now in mm
SetUserDRO(1010 , InchMM*25.4)
Else 'else it's now in inches
SetUserDRO(1010 , InchMM/25.4)
End If