07-04-2025, 12:16 AM
An even easier way to do this...
These numbers run from 1 to 100.
Make you an array to hold the values and LINES which they appear in.
Then read each line and if a number appears, add it to it's spot in that array:
Now you know which lines the data falls on. Just do a quick check to see if there's any extra _TRUE events above that line by however many spots you want.
Less nesting in there, so probably more efficient overall.
Also seems a little simpler logic to me, so easier to maintain and debug in the future, if necessary. See if it doesn't make more sense to you as well -- I tried to comment everything there to showlight my thinking, but without any actual data and whatnot, it's just pseudocode and not tested. It *looks* good to me, but there's always the chance I've goofed something simple up here.
I always reserve the right to fail.
These numbers run from 1 to 100.
Make you an array to hold the values and LINES which they appear in.
Then read each line and if a number appears, add it to it's spot in that array:
Code: (Select All)
DIM data_array(1 to 100, 1 to total_lines)
FOR i = 1 to 4500 'as you said 4500 entries
FOR j = 1 to 10
INPUT #1, the_data
data_array(the_data, i) = _TRUE
NEXT i, jNow you know which lines the data falls on. Just do a quick check to see if there's any extra _TRUE events above that line by however many spots you want.
Code: (Select All)
FOR i = 1 to 4500 'for the 4500 lines
FOR k = 1 to 100 'to check the 100 numbers
IF data_array(i, k) = _FALSE THEN _CONTINUE 'no need to check the next 7 values as this number doesn't exist on this line
FOR j = i +1 to i + 7 'to check the next 7 lines
IF j > 4500 THEN EXIT FOR 'you're above the data limit. Skip checking.
IF data_array(j, k) = _TRUE THEN 'it's a match, do whatever you want with this match. The value is k, it's on both lines i and j
NEXT
NEXT
NEXTLess nesting in there, so probably more efficient overall.
Also seems a little simpler logic to me, so easier to maintain and debug in the future, if necessary. See if it doesn't make more sense to you as well -- I tried to comment everything there to showlight my thinking, but without any actual data and whatnot, it's just pseudocode and not tested. It *looks* good to me, but there's always the chance I've goofed something simple up here.
I always reserve the right to fail.

