Posts: 381
Threads: 56
Joined: Apr 2022
Reputation:
13
Not sure why this is throwing an error
For ln = 1 To 50
Print ln, SpeedFactor(ln), Speed(ln)
Next
The error line is the For ln = 1 to 50. The error reads "Unsupported variable used in the For statement"
The "l" in the "ln" is a lower case L and not the number 1.
If I change it to For n = 1 to 50, it's fine ... no error
The other curious thing about this is, if the loop was just to Print the value of "ln" (ie For ln = 1 to 50: Print ln: Next) it runs fine, no error. So is the error actually the loop control "ln" or is it balking at the other two .. SpeedFactor(ln) or Speed(ln) both of which are correctly calculated prior to this print routine.
Again, this is not a big deal, all I need to do is change the loop control to just n, just curious why
Posts: 238
Threads: 42
Joined: May 2022
Reputation:
28
is that all there is in the loop? Can you insert the loop here? The way you describe it is untraceable. Is there by any chance a pointer value (image or sound) or a MEM field assigned to the variable ln in the loop?
Posts: 8
Threads: 0
Joined: Apr 2022
Reputation:
0
Could it be that ln is referring to/reserved for the natural logarithm? I doesn't seem like that is immediately the case in QB64PE (where the natural logarithm is LOG) (and I think it is LOG in C++ too), but still...
Just throwing that out there as a possibility...
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
Look for what you have ln defined as. Check DIM and _DEFINE type statements.
The "Unsupported variable used in the For statement" is usually one that triggers when you use an invalid variable type for the FOR..LOOP, such as a STRING variable..
Code: (Select All)
Dim ln As String
For ln = 1 To 50
' Print ln, SpeedFactor(ln), Speed(ln)
Next
Posts: 1,277
Threads: 120
Joined: Apr 2022
Reputation:
100
(09-12-2024, 07:01 PM)SMcNeill Wrote: Look for what you have ln defined as. Check DIM and _DEFINE type statements.
The "Unsupported variable used in the For statement" is usually one that triggers when you use an invalid variable type for the FOR..LOOP, such as a STRING variable..
Code: (Select All)
Dim ln As String
For ln = 1 To 50
' Print ln, SpeedFactor(ln), Speed(ln)
Next
I was thinking along this same line earlier but if this were the case then removing the arrays from the print statement and having it work means ln is a number in his case. This is a strange error he is receiving.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
Pasted as is, it works in the IDE for me. Best way to get something like this fully identified and looked into, is to zip up the file and resources (if necessary) and share them on the forums here so we can dig into it deeper.
There's not a lot of things which generate that type of error message for us, so I'm thinking a variable mismatch is coming into play somewhere/somehow with things, but it's hard to prove/test without having the actual code in front of you.
Posts: 649
Threads: 95
Joined: Apr 2022
Reputation:
22
Probably a red herring, but in Java, .in denotes data being input, as distinct from .out for output
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
216
@Dimster you are NOT showing all the code, there is no error until default 10 index is exceeded by undim'd arrays.
maybe fun to keep everyone guessing what you aren't showing?
b = b + ...
Posts: 381
Threads: 56
Joined: Apr 2022
Reputation:
13
Way, way too many lines of code to display here, but I think I may have found the problem, seem I used "ln" as a loop control in an obscure subroutine where I had "ln" again as a loop control variable but in that subroutine I had an "exit for", so maybe it was carrying over the last loop value of "ln". Then again, the "ln" should have been a local variable, I have not Dim Shared it so I wouldn't have thought to initialize it to zero before the printing of SpeedFactor and Speed.
It's ok you guys, this is not a big deal. I do appreciate the feed back and if it happens again, as the song goes " I'll stay on the bus, forget about us, put the blame on me" it's an easy error to overcome and keep on coding.
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
216
(09-13-2024, 02:46 PM)Dimster Wrote: Way, way too many lines of code to display here, but I think I may have found the problem, seem I used "ln" as a loop control in an obscure subroutine where I had "ln" again as a loop control variable but in that subroutine I had an "exit for", so maybe it was carrying over the last loop value of "ln". Then again, the "ln" should have been a local variable, I have not Dim Shared it so I wouldn't have thought to initialize it to zero before the printing of SpeedFactor and Speed.
It's ok you guys, this is not a big deal. I do appreciate the feed back and if it happens again, as the song goes " I'll stay on the bus, forget about us, put the blame on me" it's an easy error to overcome and keep on coding.
OK, probably not, but by any chance did you pass ln to the sub which will pass back changed if of same same type, main and subroutine?
name that tune: Tie A Yellow Ribbon Around The Old Oak Tree
Can you name the singer who made it famous?
b = b + ...
|