Hello Guest it is March 28, 2024, 07:41:03 PM

Author Topic: Scripter compile error in  (Read 10307 times)

0 Members and 1 Guest are viewing this topic.

Scripter compile error in
« on: January 15, 2014, 07:06:39 PM »
I'm making my own wizard with Machscreen and have run into the following problem.

When clicking on the "POST CODE" button, nothing happens, and then when clicking on the "EXIT" button, I get back into Mach 3 (the latest version) and I get the message "Scripter compiler error: In"

The VB code assigned to my "POST CODE" button is very simple and I get no syntax errors.  It starts and ends just like all the other wizards...
Sub Main()
DoOEMButton (169)
OpenTeachFile "example.tap"
...
...
...
CloseTeachFile
call LoadTeachFile()
End Sub
Main

All the lines in between are mostly:  Code "example yada yada yada"

There are a few if/then statements which decide which "code" line to print to the file, but that's pretty much it.  All of the calculations are done in the g-code itself using #*********x variables, rather than in the VBscript. This makes for easy tweaking of the gcode file without redoing the wizard.

Why the compile error?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Scripter compile error in
« Reply #1 on: January 15, 2014, 07:41:57 PM »
You're getting the Scripter Compiler error in your wizard, you probably just don't have anything to display it.
Usually, it's due to a syntax error, but without seeing the code, it's nearly impossible to say.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Scripter compile error in
« Reply #2 on: January 15, 2014, 08:43:33 PM »
Try copy/pasting all your code into the VB editor within Mach3, then either try to run it (using the buttons in the editor) or do a save-as to MCC, and the VB editor may flag the error.  Usually I find the cursor will jump to the location of the error.

Regards,
Eric Brust
Re: Scripter compile error in
« Reply #3 on: January 15, 2014, 09:17:59 PM »
Thanks for the help.  I used the editor in Mach3 and am getting the cursor to point to the syntax errors.

The first one is in an if/then statement.  Here's the snippet of code...
   If GetUserLED(1063) Then
      If FinishCutDirection = 1 Then
         Code "(Cut initial circle)                 G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut initial circle)                 G91 G2 x0 y0 i#1001 j#1002" 
      End If
      Code "(Set abs mode)                       G90" 
      Code "(Start finishing subroutine)         M98 P1234 L[90/#4005]"
      Code "(Move to final circle start)         x[#1001+#5002-#5007] y#1002 z[#1003-#2001]"
      If FinishCutDirection = 1 Then
         Code "(Cut final circle)                   G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut final circle)                   G91 G2 x0 y0 i#1001 j#1002"
      EndIf
      Else     
      Code "(Start finishing subroutine)         M98 P1234 L[360/#4005 + 1]"
   End If

It is highlighting the 3rd to last line, "Else", as the error.  Can I not nest the if/then statements as I did?
Re: Scripter compile error in
« Reply #4 on: January 15, 2014, 09:23:06 PM »
There are two more syntax errors I'm getting:  The next one is from my last 2 lines of code:
CloseTeachFile
Call LoadTeachFile()
End Sub
Main
 
It highlights "End Sub" as the error.
 
And if I comment that line out of the code, it highlights the blank space on the next line of code after "Main" which is the last line.  I keep removing any blank characters or spaces after the last line, but every time I run the code it adds that blank character back and highlights the white space in the editor where the character would be.
Re: Scripter compile error in
« Reply #5 on: January 15, 2014, 09:25:27 PM »
Thanks for the help.  I used the editor in Mach3 and am getting the cursor to point to the syntax errors.

The first one is in an if/then statement.  Here's the snippet of code...
   If GetUserLED(1063) Then
      If FinishCutDirection = 1 Then
         Code "(Cut initial circle)                 G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut initial circle)                 G91 G2 x0 y0 i#1001 j#1002"  
      End If
      Code "(Set abs mode)                       G90"  
      Code "(Start finishing subroutine)         M98 P1234 L[90/#4005]"
      Code "(Move to final circle start)         x[#1001+#5002-#5007] y#1002 z[#1003-#2001]"
      If FinishCutDirection = 1 Then
         Code "(Cut final circle)                   G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut final circle)                   G91 G2 x0 y0 i#1001 j#1002"
      EndIf
      Else    
      Code "(Start finishing subroutine)         M98 P1234 L[360/#4005 + 1]"
   End If

It is highlighting the 3rd to last line, "Else", as the error.  Can I not nest the if/then statements as I did?

If you copy/pasted exactly as the script is, you have a typo in the 'END IF' above the else statement it is failing on.  you are missing a space.  Typos get to be a killer for stuff like this :)

regards,
Eric
Re: Scripter compile error in
« Reply #6 on: January 15, 2014, 09:29:52 PM »
There are two more syntax errors I'm getting:  The next one is from my last 2 lines of code:
CloseTeachFile
Call LoadTeachFile()
End Sub
Main


  
It highlights "End Sub" as the error.
 
And if I comment that line out of the code, it highlights the blank space on the next line of code after "Main" which is the last line.  I keep removing any blank characters or spaces after the last line, but every time I run the code it adds that blank character back and highlights the white space in the editor where the character would be.

Get rid of the last 'main' (it shouldn't be there), and I think you are missing a space for 'close teachfile'.  EDIT:  'closeteachfile()' should be OK, forget my comment about the space....  good luck!

Eric
« Last Edit: January 15, 2014, 09:35:31 PM by eabrust »
Re: Scripter compile error in
« Reply #7 on: January 15, 2014, 09:35:30 PM »
Thanks for the help.  I used the editor in Mach3 and am getting the cursor to point to the syntax errors.

The first one is in an if/then statement.  Here's the snippet of code...
   If GetUserLED(1063) Then
      If FinishCutDirection = 1 Then
         Code "(Cut initial circle)                 G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut initial circle)                 G91 G2 x0 y0 i#1001 j#1002" 
      End If
      Code "(Set abs mode)                       G90" 
      Code "(Start finishing subroutine)         M98 P1234 L[90/#4005]"
      Code "(Move to final circle start)         x[#1001+#5002-#5007] y#1002 z[#1003-#2001]"
      If FinishCutDirection = 1 Then
         Code "(Cut final circle)                   G91 G3 x0 y0 i#1001 j#1002"
         Else
         Code "(Cut final circle)                   G91 G2 x0 y0 i#1001 j#1002"
      EndIf
      Else     
      Code "(Start finishing subroutine)         M98 P1234 L[360/#4005 + 1]"
   End If

It is highlighting the 3rd to last line, "Else", as the error.  Can I not nest the if/then statements as I did?

If you copy/pasted exactly as the script is, you have a typo in the 'END IF' above the else statement it is failing on.  you are missing a space.  Typos get to be a killer for stuff like this :)

regards,
Eric

Grrrr.  No matter how many times I looked at that, I missed it.  It doesn't use a space in another application I use for microchips so that's what I am used to seeing.  That's why I missed it.
Re: Scripter compile error in
« Reply #8 on: January 16, 2014, 12:55:22 AM »
One more thing, how do I fill out the description and author that is visible on the wizards menu?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Scripter compile error in
« Reply #9 on: January 16, 2014, 07:10:51 AM »
They are text labels placed on the screenset that do not display. I don't have Mach3 here, but you should be able to look at one of the default wizards and figure it out. The Mach2 customization guide also tells you how to do it.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html