Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:53 20 Sep 2026 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : Programming Issue

Author Message
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 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: Australia
Posts: 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: Australia
Posts: 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: Australia
Posts: 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 Kingdom
Posts: 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: Germany
Posts: 1772
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
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 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: Germany
Posts: 1772
Posted: 03:54am 24 Dec 2014
Copy link to clipboard 
Print this post

@edu001
  Quote  
That works but I need to call the Subs


Perhaps you should show us the subs? I think the issue must be there.



‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 04:02am 24 Dec 2014
Copy link to clipboard 
Print this post

  twofingers said   @edu001
  Quote  
That works but I need to call the Subs


Perhaps you should show us the subs? I think the issue must be there.




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 Kingdom
Posts: 4380
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: Germany
Posts: 1772
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:
  Quote  BTW, posting only part of the code makes it very hard for others to try it and help much.

I agree!

Michael

‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026