开发者

Syntax error in Ax

开发者 https://www.devze.com 2022-12-15 15:32 出处:网络
static void Job(Args _args) { int number=10; do { print (strfmt(\"current number = %1\", number)); number --;
 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 q开发者_运维技巧uestion was moved to a separate question


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号