Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: GTFreeFlyer on January 15, 2014, 07:06:39 PM

Title: Scripter compile error in
Post by: GTFreeFlyer 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?
Title: Re: Scripter compile error in
Post by: ger21 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.
Title: Re: Scripter compile error in
Post by: eabrust 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
Title: Re: Scripter compile error in
Post by: GTFreeFlyer 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?
Title: Re: Scripter compile error in
Post by: GTFreeFlyer 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.
Title: Re: Scripter compile error in
Post by: eabrust 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
Title: Re: Scripter compile error in
Post by: eabrust 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
Title: Re: Scripter compile error in
Post by: GTFreeFlyer 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.
Title: Re: Scripter compile error in
Post by: GTFreeFlyer 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?
Title: Re: Scripter compile error in
Post by: ger21 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.
Title: Re: Scripter compile error in
Post by: eabrust on January 16, 2014, 08:11:05 PM
GT,

The labels Ger21 mentioned just get text put in them as follows:

for author:  Author text_you_want_displayed
for description:  Desc text_you_want_displayed

I believe you can place them anywhere in the screenset, and they are automatically hidden from view.

regards,
Eric
Title: Re: Scripter compile error in
Post by: GTFreeFlyer on January 17, 2014, 11:23:20 AM
Yes thank you all for the info.  I seem to have the wizard working.  I plan to try my first cuts with it today.  I'll keep you posted on the progress.
Title: Re: Scripter compile error in
Post by: GTFreeFlyer on January 18, 2014, 12:32:01 PM
Working great so far.  I'm just fixing up some minor bugs.

Video:
http://www.youtube.com/watch?v=NFQ1A37kcGA&noredirect=1

Wizard screenshot:
https://www.dropbox.com/s/10addl8i6zrd3gg/screenshot.JPG
Title: Re: Scripter compile error in
Post by: eabrust on January 18, 2014, 12:40:21 PM
Working great so far.  I'm just fixing up some minor bugs.


That kicks butt!  (in a good way of course!!)  ;D