3
 static void Job(Args _args) 
 { 
    int number=10;
    do
     {
        print (strfmt("current number = %1", number));
        number --;
     }while (number != 0)  
  }

This is a job just for testing do-while in X++ , and I get a "syntax error" in the last '}'

I'm new to Dynamics AX and to X++, so I don't know if there's something I'm missing, but I'd say it should work.

-----[EDIT]-----
second part of the question was moved to a separate question

Community
  • 1
  • 1
Marcelo
  • 3,371
  • 10
  • 45
  • 76

1 Answers1

5

As in many C style languages, the DO WHILE loop does require a semicolon at the end of the while test:

http://msdn.microsoft.com/en-us/library/aa842320.aspx

SYNTAX

do
{ statement }
while
( expression ) ;

Fixed code:

static void Job(Args _args) 
{ 
  int number=10;
  do
   {
      print (strfmt("current number = %1", number));
      number --;
   }while (number != 0); <-- semicolon required here
}

The reason the error doesn't occur until the final brace is that the compiler doesn't realize there's something missing until that point in the code.

Community
  • 1
  • 1
Adam Davis
  • 91,931
  • 60
  • 264
  • 330
  • thank you! +1, now, how am i supposed to notice other errors in more complex statements further on ? any tips to add ? – Marcelo Jan 04 '10 at 17:45
  • The second part of your question is better left as a separate question, so I created one for it here: http://stackoverflow.com/questions/2001069/understanding-compiler-error-messages – Adam Davis Jan 04 '10 at 17:58
  • i'll do another one myself, i'm not talking about any language, i'm talking about x++ debugging in dynamics ax, i don't want generic techniques, i want tools in dynamics, or being told that there are none and that i should give up trying to find an easier way and just know every error by heart. – Marcelo Jan 04 '10 at 18:16
  • question made, already updated this one, check out in the "separate question" link in the end. – Marcelo Jan 04 '10 at 18:21