Hi
@Kiara87 So no 60's but new math on 30's. Why wasn't the 90 - 60 = 30 shaded in the screenshot I showed and blue circled, because don't check 90? only numbers less than 90?
OK this can be done now that I've leaned the new math 79 + 30 = 109 - 90 = 19 ha! ;-)
And we need to check down the whole column that one line in the data file makes.
We could make things easy on ourselves by loading a into an array with rows and columns just like the print out.
Starting at MID$(a, 5, 2) I think, every 2 digits is new number, 5 numbers make a row so the next row of numbers after 5 starts at 15 and the next starts at 25 and the next starts at 35... positions in the "a" string I am talking about.
How many rows in one line from the file? nRows = (len(a) - 4) /10 it's a constant for the DAT file we use, the first 4 digits are identifiers to line I suppose those should go in a separate array or just read off "a" when we need them.
DIM lineDAT(1 to 5, 1 to nRows) as INTEGER 'an array to load from each line from DAT
rowCnt = 0 : x = 1 : y = 1
for i = 5 to len(a) step 2
d = val(mid$(a, i, 2)) 'convert data item to iteger
rowCnt = rowCnt + 1 ' increase column if at 6 start new row
if rowCnt = 6 then x = 1 : y = y + 1
lineDAT(x, y) = d
next
The above is NOT in code box because it is not tested in QB64.
That loads our line data array and it makes it easy to sweep through array and make red the items that are 30 from each other.
I would just print the array as white and then print the 30's red after a sweep the array check for 30's.
Before starting an 2D array for line data I would start an array for the file data and load whole file into array.
This is standard way to approach data from a file, load the file into an array in programs working memory it is way more efficient to process file data from some sort of array.
So next step is to do that, load the file data into an array of strings and we already know the amount of lines 480
Dim FileDAT(1 to 480) as STRING
Open File for input
for i = 1 to 480
Get a line of data from file
and set FileDAT(i) = to it
next i
'array loaded with data from file
' next use the the code we wrote to get a line number only this time we will get it from the array instead of the file
Let's see how far along you can get with that. Get the lines from the array and printout the screen of data.
Then we will work on scanning down the columns for 30's, the code above is start of that. We should also have to write a FUNCTION for your new math with 30s. ;-)
OK?
Oh, once we know what lineNum to get from key presses we just set a = LineDAT(lineNum) simple!
And now we can get any lineNum we want, we don't have to just go up and down the file for a data line.