Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select Case error
#1
[Image: Error-using-Select-Case.png]


I have run into a situation where the IDE is showing an error in my use of a Select Case. I have 4 cases the last one being Case "Extreme". Attached is a clip of the code and warning box. Normally this would mean I have missed an End IF or a Next but at the moment I can't seem to find it.. I'll keep looking but my question here is that mysterious "7" which you see in the warning box which highlights Case "Extreme" , 7 .... there is no 7 on that case line. Any idea what that 7 means and if it may be pointing me to where I need to address the problem?
Reply
#2
(12-14-2023, 04:39 PM)Dimster Wrote: [Image: Error-using-Select-Case.png]

picture sharing

I have run into a situation where the IDE is showing an error in my use of a Select Case. I have 4 cases the last one being Case "Extreme". Attached is a clip of the code and warning box. Normally this would mean I have missed an End IF or a Next but at the moment I can't seem to find it.. I'll keep looking but my question here is that mysterious "7" which you see in the warning box which highlights Case "Extreme" , 7 .... there is no 7 on that case line. Any idea what that 7 means and if it may be pointing me to where I need to address the problem?

Looks like you're missing the next for the "For g = 1 to 8" loop. (The first instance of that line not the second lower down...)
Reply
#3
Not sure I'm seeing it Mr. Naked. And as an aside, I can't believe I posted this image with those damn ads attached to it. How did that happen? Sorry to those you find that annoying as hell.
Reply
#4
(12-14-2023, 05:37 PM)Dimster Wrote: Not sure I'm seeing it Mr. Naked. And as an aside, I can't believe I posted this image with those damn ads attached to it. How did that happen? Sorry to those you find that annoying as hell.

lol, you can call me Ted. Now I regret my username. I see no ads btw.

Line 2456: the FOR statement has no corresponding NEXT
Reply
#5
(12-14-2023, 04:50 PM)NakedApe Wrote:
(12-14-2023, 04:39 PM)Dimster Wrote: [Image: Error-using-Select-Case.png]

picture sharing

I have run into a situation where the IDE is showing an error in my use of a Select Case. I have 4 cases the last one being Case "Extreme". Attached is a clip of the code and warning box. Normally this would mean I have missed an End IF or a Next but at the moment I can't seem to find it.. I'll keep looking but my question here is that mysterious "7" which you see in the warning box which highlights Case "Extreme" , 7 .... there is no 7 on that case line. Any idea what that 7 means and if it may be pointing me to where I need to address the problem?

Looks like you're missing the next for the "For g = 1 to 8" loop. (The first instance of that line not the second lower down...)

G cycle is not completed  (missing 'next g')
Reply
#6
That , 7 is part of the translated code and represents the length of text.

"extreme", 7

^ there's 7 characters in "extreme"
Reply
#7
What happened that the source code couldn't be posted as ordinary "code" block here?

This is because earlier I kept getting a 502 trying to open the screenshot.

YOU CANNOT USE TWO g VARIABLES in consecutively nested FOR/NEXT loops!

I don't know if QB64 would even permit it. But the outer loop will execute once. It's because the inner one will set that variable to 8, then when the processor goes to the outer "FOR" line, for the same exact variable it thinks, "OK it's 1 to 8 but the value is nine so I give up". :O

Actually the IDE doesn't know what to blame because the programmer failed to close a loop. The two variables for "FOR/NEXT" must have different names, and each loop should be closed properly inside the "CASE" and before "END SELECT".

Change one of the g variables of the loop control, then add another "NEXT" at the bottom, before "END SELECT" statement. Without it, the program will not compile.
Reply
#8
You *can* namr two loops with the same variable name.  It's probably not going to work the way you'd expect, but it is perfectly valid.

The problem is the lack of the enclosing NEXT for that first FOR.
Reply
#9
Thanks Ted and all. It was like finding Waldo.
On the multiple uses of the g control variable. I do this often to find a letter with some meaning to the array or formula to which the looping is associated. That way I can search for just that letter if I'm getting questionable results from either a formula or a display of values from an array. I also find that a complicated For/Next loop or IF/ ENDIF seems to be slower than breaking the decision up into smaller multiple loops. And MNRV I'm finding, as long as I run the loop to its end (ie no nesting) I can reuse the same control variable name, like g as many times as I want.

Thanks again for the speedy find of my problem (I'm a slow coded and would have found the solution some time after Christmas) and the explanation of the 7.

Still upset with myself for attaching an image with ads. You guys must have ad blockers because every time I click on the image I uploaded I get flashing ads. I'll have to pay attention to how I did this or no more uploading of those dazzling images of my coding.
Reply
#10
@Dimster
You can upload an image as an attachment and then use "Insert into post" or something and it will still put it in the body of your post but without the external website.
Tread on those who tread on you

Reply




Users browsing this thread: 1 Guest(s)