586,105 active members*
3,322 visitors online*
Register for free
Login
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    11

    Macro to set variables from a barcode

    I would like some help to write a Mach3 Macro.
    I have a Mach3 application, that I use in a production environment, I have product that I want to machine that comes in different sizes with different options. The products comes with two barcodes.
    The first barcode I read, I use to load the GCode file. Ie A12-3B loads A12-3B.tap… this works fine.
    The second barcode I want to use to set parameters in a Macro for SIZE and TYPE of product to be machined.

    So after starting Gcode program an M999 Macro is executed that asks a question “Please Scan Second Barcode?” An example of this scanned barcode would be “Size1TypeA1”, or “Size2TypeB2”
    I need to know the SIZE eg. Size1 to set a G52 command for Z-height offset
    I need to know the TYPE eg. TypeA1 to go to subprogram m98(A1.tap)

    Below I have code that I have written, In Italic I have written the logic that I am trying to achieve.

    In summary, I am trying to read a single barcode and extract two separate pieces of information to use one for a G52 height offset and the second to create a subprogram name.

    I would greatly appreciate some help to get this programing to work.
    --------------------------------------------------------

    Dim SizeTypeVar As String


    SizeTypeVar = Question("Please Scan Second Barcode? Eg. Size1TypeA1 ")

    If [the 5th Character of ]SizeTypeVar= 1 Then
    Code ("G52 Z-6.")
    End If
    If [the 5th Character of ] SizeTypeVar = 2 Then
    Code ("G52 Z-5.")
    End If


    If [the 10th, 11th Character of ] SizeTypeVar = A1 Then
    Code ("M98 (A1.TAP) L1”)
    End If
    If [the 10th, 11th Character of ] SizeType = B2 Then
    Code ("M98 (B2.TAP) L1”)
    End If
    -------------------------------------------------------

  2. #2
    Join Date
    Oct 2005
    Posts
    1145

    Re: Macro to set variables from a barcode

    This should help you along the way (;-)

    Option Explicit

    Private Sub Form_Load()
    Dim sVar As String
    Dim Svar2 As String
    Svar = AskTextQuestion("2nd Barcode ?")

    'Svar = "Size1TypeA1" 'Subsitute Value for Barcode for testing

    MsgBox Mid$(sVar, 5, 1)

    Svar2 = Mid$(Svar,10,1) & Mid$(Svar,11,1)
    MsgBox "" & Svar2

    End Sub

    (;-) TP

  3. #3

    Re: Macro to set variables from a barcode

    Only can find macro for bar code in excel on CodeProject, I'm not sure whether it can help you.

Similar Threads

  1. where are the macro variables stored
    By dertsap in forum Mach Software (ArtSoft software)
    Replies: 3
    Last Post: 10-29-2012, 04:20 AM
  2. Macro Variables
    By donwatt in forum Controller & Computer Solutions
    Replies: 0
    Last Post: 06-25-2010, 06:30 PM
  3. macro variables
    By sinha_nsit in forum Fanuc
    Replies: 5
    Last Post: 01-15-2008, 10:42 AM
  4. Variables/Macro uses....
    By theemudracer in forum Fanuc
    Replies: 12
    Last Post: 12-13-2006, 08:45 PM
  5. Variables/Macro use ????
    By theemudracer in forum G-Code Programing
    Replies: 2
    Last Post: 12-11-2006, 04:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •