Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does my Loop end after 11 Loops?
#7
Code: (Select All)
dim ditem(1 to 7) as long
dim as long ff, count, total

count = 1
ff = freefile
open "example.dat" for input as ff
do until eof(ff)
    total = total + 1
    input #ff, ditem(count)
    count = count + 1
    if count > 7 then
        count = 1
        gosub dosomethingwithdataitems
    end if
    if total >= 4000 then exit do
loop
close ff

if total < 4000 then
    print "Unexpected end of data items"
    if count > 1 then print "Incomplete data set"
end if
end

dosomethingwithdataitems:
'put code here to do something with ditem()
return

This is how I would have done things, as I've studied from the first post of this topic. As I've said, no need for recursion. No need to seek back to the beginning of the file.
Reply


Messages In This Thread
Why does my Loop end after 11 Loops? - by Dimster - 02-06-2023, 07:08 PM
RE: Why does my Loop end after 11 Loops? - by mnrvovrfc - 02-06-2023, 10:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Exiting sub while inside a loop PhilOfPerth 5 523 12-05-2025, 09:40 AM
Last Post: PhilOfPerth
  Do Loop, Sleep and Mouse Button Dimster 5 599 09-06-2025, 12:57 PM
Last Post: Dimster
  Using modulo to loop through lists fistfullofnails 3 723 09-03-2025, 11:50 PM
Last Post: fistfullofnails
  What is wrong with this for/next loop Helium5793 6 1,144 04-15-2025, 05:11 PM
Last Post: Kernelpanic
  Question on ln in a for/next loop Dimster 13 2,244 09-13-2024, 11:07 PM
Last Post: Kernelpanic

Forum Jump:


Users browsing this thread: 1 Guest(s)