Liberty BASIC Community Forum
« Need some help please »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 1:02pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Need some help please  (Read 238 times)
milfredo
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 113
xx Need some help please
« Thread started on: Sep 25th, 2017, 11:26pm »

Here is a piece of code. racenumfile is 169 fyle starts out as 1 and then proceeds into the program and executes nicely. Then when it loops back to the Next fyle it doesn't continue to the next fyle, it goes to the Return command just after Next fyle. I don't understand why the Next loop doesn't execute after the first loop.

cursor hourglass
for fyle = 1 to racenumfile ' where we start matching files looking for race date to handicap.
fi$ = raceinfo$(fyle, 0)
fileName$ = mid$(fi$,1,11)
filedate$ = mid$(fi$,4,4)

IF filedate$ = handicapdate$ then ' check to see if file is matching date.
Racefolder$="C:\2017\Q2_2017"
RacefullFname$= Racefolder$ +"\" + fileName$
Goto [processfile]

ELSE
goto [nomatch] ' if not matching date then go to next fyle
End If






[nomatch]
Next fyle

Return ' to [loadracefiles]


Thanks for any help,
Milfredo
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5617
xx Re: Need some help please
« Reply #1 on: Sep 26th, 2017, 02:27am »

You should not be jumping out the for next loop with go to. Use gosub processfile instead. That way you will return inside the for next loop and the race counter will increase.

Using goto you are probably starting the for next loop again and so it always starts with 1
User IP Logged

milfredo
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 113
xx Re: Need some help please
« Reply #2 on: Sep 26th, 2017, 2:13pm »

I changed it to Gosub but the same problem exists. Does it matter that within the code of the for loop I jump around to a couple of processes and then Return to the For Next loop?
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1728
xx Re: Need some help please
« Reply #3 on: Sep 26th, 2017, 2:20pm »

It shouldn't.
So it is likely that your program somehow misses right turn and hit NEXT after going out of loop
(my guess that it could be out of WHILE loop too - it seems to mess loop stack as well)

(buit it's hard to tell without runnable code)
« Last Edit: Sep 26th, 2017, 2:20pm by tsh73 » User IP Logged

damned Dog in the Manger
milfredo
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 113
xx Re: Need some help please
« Reply #4 on: Sep 26th, 2017, 5:07pm »

In the body of the code, I had another for next loop that I jumped out of using a 'Goto' command.

I replaced it with:

if Horseput = numberhorses-1 then exit for

and this seems to have cleared up the problem.

Thanks so much for helping me think the problem through. You guys are the best.

Milfredo
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls