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
-------------------------------------------------------