QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: lawsonm1 on April 13, 2020, 11:31:26 am
-
Believe it or not; I'm going to step in the world of multi-dimensional arrays for the first time. I wrote a program that captures two pieces of data from a website every 5 minutes. This is done five times a week. My question is how the dimensions should be listed; least number of possibilities to most number of possibilities, the reverse of that, it doesn't matter, it depends on how the array is used, or some other method?
The 5 minute interval is always a constant 120 (10 hours), to that one would always be dimensioned to a max of 120. Since there are only two possibilities for each data capture, the maximum there would be 2. But since this data is captured five days a week, that one would grow to be the largest.
Any thoughts or opinions? Thanks, Mike
-
REDIM mydata(120, 2)
Then dump those array results into an APPEND daily file, and loop back through the process as many times as you want.
Pete
-
Hi lawsonm1
Homework:
1. take 2 pieces of data at a time
2. repeat that taking data every 5 minutes for 10 hours in a day (10 hours /5 minutes = 120 times)
3. repeat that daily taking data for 5 days in a week
4. using a multidimensional array...
it maybe for my not native english language but I need more information:
A. are the 2 pieces of data of the same kind? for example Integer, Long, String .... User Defined Data
B. are the 2 piece of data after 5 minutes changed or they are stored somewhere?
C. is multidimensional array a must? for example if you manage multiple kind of data in parallel without UDT
after this I can give my two cents,
but Pete have given you a good approach to the problem.
-
I have been doing some thinking of this. I think the way I may proceed is by reading each day's data file, perform the necessary math on the 120 records I have for that day, on each of the two pieces of data I extract every five minutes. Once the math has been done, save the results to a new file. And then start the process all over again with the next day's data. Thanks, Mike
-
So in pseudocode
anotherweek:
anotherday:
again:
get/input data1 from day's data file
get/input data2 from day's data file
make math routine on these data1 and data2
save results into the new file
wait 5 minutes
goto again
when got 120 records stop
wait for the newday
newday ++
if newday <6 goto anotherday
wait for the newday
wait for the newday
goto anotherweek
in this perspective if you like can use a multidimensional array as an option of coding
but you can use just 2 different variable of the same kind of data.
Fine task to perform.