Welcome! Log In Create A New Profile

Advanced

For and Select loop bug

Posted by robertkendrick 
For and Select loop bug
February 07, 2013 12:17AM
There seems to be a problem with this code.
It transfers ok to the chip and compiles without error.
However when run it produces the error shown in the screenshot.
Surely it is ok to use a select statement inside a for/next loop ??

#option only on   // only load functions that don't already exist

function xxx()
    dim i
    for i = 0 to 2
      select(i)
        case(0)
          print("Zero")
          break
        case(1)
          print("One")
          break
        case(2)
          print("two")
          break
      endselect
    next
endf





Edited 1 time(s). Last edit at 02/07/2013 12:58AM by robertkendrick.
Re: For and Select loop bug
February 07, 2013 08:21AM
hello,
there is a bug when select is used inside for/next which has not been fixed yet (See 2.05). The work round is to use while wend instead.

Also the print statement does not have brackets.



Edited 1 time(s). Last edit at 07/15/2014 06:24AM by jimeer.
Re: For and Select loop bug
February 07, 2013 10:02AM
Ok. Thanks.
Yes, found the print syntax errors myself. Suffering from language blur from the different prog languages.
Should have checked your bug list.

By the way, the list(x) command seems to be missing. Documentation says it applies to MX1 but list(1) or list(2) gives errors.
Re: For and Select loop bug
February 07, 2013 11:16AM
Thanks for pointing that out. I have updated the documentation. It is not available for MX1 as the name of the function is not stored, again to save as much space as possible.
Sorry, you do not have permission to post/reply in this forum.