Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error in Ax

 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

like image 307
Marcelo Avatar asked Feb 02 '26 10:02

Marcelo


1 Answers

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.

like image 101
Adam Davis Avatar answered Feb 04 '26 00:02

Adam Davis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!