Hello Guest it is March 29, 2024, 08:36:12 AM

Show Posts

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.


Messages - stirling

831
Glad you're sorted.

Ian

832
I take it you have a user dro (number 1010) a user LED (number 1012) AND a button set to use VB code on your screenset? if so put this in your button.

Code: [Select]
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

833
so you don't want to change system units or anything else?

just a USER DRO -( not an axis DRO, a feedrate DRO or any other SYSTEM DRO ) that flips between the two values when you click the button?

834
Kenneth I can't help you unless you tell me simply and concisely what your goal is. Forget buttons, LEDs and DROs and the rest for a moment - just say what your overall aim is.

835
You need to be clear what it is you want to do. If ALL you want is...

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.

Then WHY are you toggling the system units?

836
optimized and cleaned up a tad.

Code: [Select]
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


Ian

837
VB and the development of wizards / Re: need help in vbscript
« on: March 11, 2013, 09:27:33 AM »
my teacher wants us to experiment on vbscipt but i dont have any idea...

...and you never will have any idea unless you stop being a lazy little so and so. Stop asking for someone else to do the work - get off your lazy behind and google and read and WORK.


838
I'm not entirely clear what it is you want to do.... however....

Your USER DRO was just mimicking the SYSTEM units DRO so there's no point in having it. Try this code and see if it does what you want.

Note that whenever you change the system units then the axis DROs WILL change UNLESS you have "Lock DROs to setup units" ticked in general config.

Code: [Select]
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

Ian

839
Newfangled Mill Wizard / Re: Button to select one wizard ?
« on: March 06, 2013, 11:46:16 AM »
LoadWizard "Pocket Cutting"

Ian

840
Newfangled Mill Wizard / Re: Button to select one wizard ?
« on: March 06, 2013, 11:01:57 AM »
see support/Mach wiki at the top of this page. scroll down to "Mach specific Subroutines/Functions grouped by purpose" then "9 Screen handling routines for wizards etc."

All sorts of goodies (and baddies)

including LoadWizard()

Ian