Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 10:50pm 23 Dec 2014
Copy link to clipboard
Print this post
Hi
I have these two FOR NEXT loops that are almost identical the problem I have is that the first one(FOR t = 1) runs perfectly but the second one (FOR u = 1) throws up the error
Next u
Error cannot find matching FOR
Outv$ = "$$$$$$$$"+Out$+"*"+chk$+Chr$(13)
PRINT Outv$
for t = 1 to len(Outv$)
txtchr = Asc(Mid$(Outv$, t, 1))
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
tra 'Call tra SUB
trb 'Call trb SUB
trc 'Call trc SUB
next t
'TX 'call SUB TX
'pwrselect
ELSE
pin(5) = 1
NoGPS$ = "No GPS, Temp "+B20$+", Volts "+STR$(BVOLT)+Chr$(13)
PRINT NoGPS$ 'edit out when flying
for u = 1 to len(NoGPS$)
txtchr = Asc(Mid$(NoGPS$, u, 1))
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
tra 'Call tra SUB
trb 'Call trb SUB
trc 'Call trc SUB
next u
Any Ideas ?
BobD
Guru
Joined: 07/12/2011 Location: AustraliaPosts: 935
Posted: 11:31pm 23 Dec 2014
Copy link to clipboard
Print this post
You could try this line just before the loop.
Print len(NoGPS$)
It may be useful to see what value is assigned to it.
BobD
Guru
Joined: 07/12/2011 Location: AustraliaPosts: 935
Posted: 11:52pm 23 Dec 2014
Copy link to clipboard
Print this post
If the length is what you expect then try commenting out all of the 6 statements in the loop. Does it still show the same error? If not then add the statement back in one at a time.
BobD
Guru
Joined: 07/12/2011 Location: AustraliaPosts: 935
Posted: 12:28am 24 Dec 2014
Copy link to clipboard
Print this post
The line "Next u" may be corrupted. Comment it the line out and add a new line with the same statement.
Merry Christmas to all.
edu001 Regular Member
Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 01:05am 24 Dec 2014
Copy link to clipboard
Print this post
Thanks BobD
Tried all of the above the LEN(NoGPS$) is as expected
I have deleted and re created the whole thing still no go
I just cant see why it would cause an error
twofingers Guru
Joined: 02/06/2014 Location: GermanyPosts: 1141
Posted: 01:59am 24 Dec 2014
Copy link to clipboard
Print this post
@edu001
just see what happens if you "rem-out" (mask) the calls to the subs (tra, ...).
Regards Michael
for u = 1 to len(NoGPS$)
txtchr = Asc(Mid$(NoGPS$, u, 1))
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
REM tra 'Call tra SUB
REM trb 'Call trb SUB
REM trc 'Call trc SUB
next u
Edited by twofingers 2014-12-25
edu001 Regular Member
Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 03:50am 24 Dec 2014
Copy link to clipboard
Print this post
Thanks twofingers
That works but I need to call the Subs
twofingers Guru
Joined: 02/06/2014 Location: GermanyPosts: 1141
Posted: 03:54am 24 Dec 2014
Copy link to clipboard
Print this post
@edu001
Perhaps you should show us the subs? I think the issue must be there.
edu001 Regular Member
Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 04:02am 24 Dec 2014
Copy link to clipboard
Print this post
Ok the code is on another machine
The first FOR NEXT calls them no problem and if i run the SUB code in the main programme it also works odd ?
JohnS Guru
Joined: 18/11/2011 Location: United KingdomPosts: 3678
Posted: 04:36am 24 Dec 2014
Copy link to clipboard
Print this post
There looks to be a stray
ELSE
about half way down.
BTW, posting only part of the code makes it very hard for others to try it and help much.
John
twofingers Guru
Joined: 02/06/2014 Location: GermanyPosts: 1141
Posted: 11:36am 24 Dec 2014
Copy link to clipboard
Print this post
@edu001
please check your subs:
1. Do you strict use local variables?
2. Do you use a Exit (or Exit Loop) there?
Plz try this (exchanged "u" to "t"):
Outv$ = "$$$$$$$$"+Out$+"*"+chk$+Chr$(13)
PRINT Outv$
for t = 1 to len(Outv$)
txtchr = Asc(Mid$(Outv$, t, 1))
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
tra 'Call tra SUB
trb 'Call trb SUB
trc 'Call trc SUB
next t
'TX 'call SUB TX
'pwrselect
ELSE
pin(5) = 1
NoGPS$ = "No GPS, Temp "+B20$+", Volts "+STR$(BVOLT)+Chr$(13)
PRINT NoGPS$ 'edit out when flying
for t = 1 to len(NoGPS$)
txtchr = Asc(Mid$(NoGPS$, t, 1))
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
tra 'Call tra SUB
trb 'Call trb SUB
trc 'Call trc SUB
next t
I don't see the reason to use two different variables (t and u).
As John says:
BTW, posting only part of the code makes it very hard for others to try it and help much.