Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Seeking Matches in a Data Base
#4
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:
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, j

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.
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
NEXT

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.  Big Grin
Reply


Messages In This Thread
Seeking Matches in a Data Base - by Dimster - 07-03-2025, 04:00 PM
RE: Seeking Matches in a Data Base - by SMcNeill - 07-03-2025, 04:44 PM
RE: Seeking Matches in a Data Base - by Dimster - 07-03-2025, 08:08 PM
RE: Seeking Matches in a Data Base - by SMcNeill - 07-04-2025, 12:16 AM
RE: Seeking Matches in a Data Base - by Dimster - 07-04-2025, 06:24 PM
RE: Seeking Matches in a Data Base - by Dimster - 07-05-2025, 02:40 PM
RE: Seeking Matches in a Data Base - by SMcNeill - 07-05-2025, 04:33 PM
RE: Seeking Matches in a Data Base - by Dimster - 07-06-2025, 02:42 PM
RE: Seeking Matches in a Data Base - by SMcNeill - 07-06-2025, 04:23 PM
RE: Seeking Matches in a Data Base - by Dimster - 07-07-2025, 03:51 PM
RE: Seeking Matches in a Data Base - by Dimster - 07-13-2025, 12:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Must an extra value be provided on DATA statement? dakra137 11 1,062 09-30-2025, 05:38 PM
Last Post: ahenry3068
  Why is 'base' treated like a reserved word in the IDE? Pete 4 807 04-11-2025, 09:49 PM
Last Post: SMcNeill
  Change file data krovit 5 1,213 07-11-2024, 07:45 AM
Last Post: krovit
  Arrays In User Data Types Consolemu 2 878 01-18-2024, 09:49 PM
Last Post: bplus
  Write data to EXE file Steffan-68 8 2,025 05-15-2023, 06:41 PM
Last Post: Steffan-68

Forum Jump:


Users browsing this thread: 1 Guest(s)