Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For..Next
#6
Yes DSMan the error warning is sometimes unhelpful in finding where the problems is and it would seem the IDE would already have the various clues to help for quicker detection of where to go in your code to fix the offence. Here is an example :

Code: (Select All)
For x = 1 To 5
    If x + 1 = 3 Then
        Print "Still within the x loop"
        Print "Loop is 1 to 5, loop variable x presently is "; x + 1
        For m = x + 1 To x + 4
            If x + 1 = 5 Then
                Print "At the end of the x loop"
                Print "The next x value will be 6 so none of this will be printer"

                For y = 1 To 3
                    Print "Value of y is now "; y
                Next
                For z = 1 To 4
                    Print "Value of z is now "; z
                Next
Next

So here if the error warning highlights that last NEXT but that NEXT is not the problem. There are 2 problems in this code. The NEXT associated with the FOR M loop is missing. I'm thinking the IDE here in this example is warning of a missing NEXT "m" and not a NEXT "x" which it is highlighting. 

It's either that or the IDE is running through the code top to bottom and the first error it's finding is that "IF x+1=5" condition does not have an END IF. Which I believe is exactly what you are pointing out. It would be great if the warning was as you laid out "Expected an END IF but found a NEXT"

What I was thinking was if the IDE could complete the control variables (ie Next y, Next z, Next x) if there is an error in the code then its a little easier to see a missing Next m,. And if there are no missing Next variables, then the issue has to be a missing END IF or End Select etc.

So great to have a forum you bounce these crazy ideas off of.
Reply


Messages In This Thread
For..Next - by Dimster - 05-17-2024, 03:27 PM
RE: For..Next - by SMcNeill - 05-17-2024, 03:58 PM
RE: For..Next - by Dimster - 05-17-2024, 05:00 PM
RE: For..Next - by PhilOfPerth - 05-18-2024, 01:56 AM
RE: For..Next - by DSMan195276 - 05-18-2024, 04:28 AM
RE: For..Next - by Dimster - 05-18-2024, 01:09 PM
RE: For..Next - by Kernelpanic - 05-18-2024, 03:48 PM



Users browsing this thread: 3 Guest(s)