Macro script error

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Macro script error

Postby loesch » Tue Apr 28, 2020 9:04 pm

I present my back for the floggings that will come, but I'm new to C# and writing macros. I have a simple message box macro which only has 11 lines. When I try to run it, errorlog says I have an error in line 18. So how do I use the line numbers to debug my code? I have looked at it carefully, but I must be missing something. The macro and errorlog are attached for those that want to look at it, but my question is with how the compiler numbers lines.


MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show("Has probe been removed to a safe location?","Probe SAFE", buttons);
if (result == DialogResult.No) {
exec.Stop();
return;
}
else {
exec.Code("G1 F300 Z20");
While(exec.IsMoving()){}
exec.Wait(1000);
}


UCCNC macro compiler error log file
--------------------------------------
Last error dated: 4/28/2020 4:56:27 PM
In macro: M20004
--------------------------------------
CS1002 | in line: 18 | error text: ; expected
--------------------------------------
Attachments
Errorlog.txt
(262 Bytes) Downloaded 536 times
Macro.txt
(338 Bytes) Downloaded 546 times
loesch
 
Posts: 28
Joined: Sat Jan 28, 2017 11:18 pm

Re: Macro script error

Postby beefy » Tue Apr 28, 2020 10:51 pm

Will this fix it:

While(exec.IsMoving();){}
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

Re: Macro script error

Postby cncdrive » Tue Apr 28, 2020 11:22 pm

Yes you forgot a ; after the function call.
You could use Visual Basic language if you don't like this. :)
Just put #VB in the very first line of the macro to program in VB. (I've mentiond this because maybe you did not know and you might like VB better than C#)
cncdrive
Site Admin
 
Posts: 4888
Joined: Tue Aug 12, 2014 11:17 pm

Re: Macro script error

Postby loesch » Wed Apr 29, 2020 3:16 pm

Well, I tried adding a ; after the function call as beefy recommended, with no change. Get the same error of expecting a ; in line 18 (but there are only 11 lines of code in the macro). Also, I have several other macros which use the exact same "While(exec.IsMoving()){}" without the recommended ; and they all work fine (no errors). Something else seems to be going one. Will keep plugging away.

Is there anyway of seeing in UCCNC a debugging screen that actually shows the line of code that it doesn't like other than just a line number which doesn't seem to correlate with actual code?
loesch
 
Posts: 28
Joined: Sat Jan 28, 2017 11:18 pm

Re: Macro script error

Postby cncdrive » Wed Apr 29, 2020 3:31 pm

Sorry, it was too late night for me when I replied this. :(
No, you do not have to put ; there.
The issue is that you wrote the while with capital W, it should be not While, but while.
cncdrive
Site Admin
 
Posts: 4888
Joined: Tue Aug 12, 2014 11:17 pm

Re: Macro script error

Postby Vmax549 » Wed Apr 29, 2020 4:20 pm

What they are not telling you is there is a 10 line offset in teh error reporting. So if it said line 18 it would really be around line 8 of teh macro.

Just a thought , (;-) TP
Vmax549
 
Posts: 331
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Macro script error

Postby loesch » Wed Apr 29, 2020 11:55 pm

Thank you to all that offered a helping hand. This brought back my old fortran programming days where you can stare directly at an error for days and not see something so simple. Thanks to cncdrive for pointing out the caps error. Stay safe.
loesch
 
Posts: 28
Joined: Sat Jan 28, 2017 11:18 pm

Re: Macro script error

Postby beefy » Thu Apr 30, 2020 10:59 pm

loesch wrote:This brought back my old fortran programming days where you can stare directly at an error for days and not see something so simple.


Ha ha, dead right, been down that road several times :lol:
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 3 guests