By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

Saving array data to a file (.dat, .txt, access or excel)

P: 1
Hi first time so bear with me, I have a program that records the split and length times of swimmers, upto 8 lanes and upto a distance of what ever i create the array the program works really well and still under development, but am struggling with a way to save the data for obvious future analysis, I am quite willing to send the code if you can help.

Thanks
Warlop3
Nov 12 '06 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,646
Hi first time so bear with me, I have a program that records the split and length times of swimmers, upto 8 lanes and upto a distance of what ever i create the array the program works really well and still under development, but am struggling with a way to save the data for obvious future analysis, I am quite willing to send the code if you can help.

Thanks
Warlop3
Hi. Post the code please or email it to me if you prefer.
Nov 12 '06 #2

Expert 5K+
P: 8,434
Hi. Post the code please or email it to me if you prefer.
(Sorry willakawill, just can't help myself... :))

I do have some thoughts on this one, as I've just been doing something similar. One method (certainly not the only one, and not necessarily the best) is to open your data file in binary mode and simply PUT the array. Then you can GET it later.

I recommend storing additional information which may be required when reading it back, such as the dimensions of the array. Very simple example...

To save
Expand|Select|Wrap|Line Numbers
  1. Open "MyFile.dat" For Binary Access Write Lock Write As #1
  2. Put #1, , ArraySize
  3. Put #1, , MyArray()
  4. Close #1
To read back
Expand|Select|Wrap|Line Numbers
  1. Open "MyFile.dat" For Binary Access Read Shared As #1
  2. Get #1, , ArraySize
  3. ReDim MyArray(1 To ArraySize) ' May be unnecessary? Can't remember.
  4. Get #1, , MyArray()
  5. Close #1
Something else I recommend to everyone is to store something human-readable in your data files, preferably either at the very start or the very end, which visually identifies what the file is for. In other words, when you come across some data file ten years later and wonder why it exists and whether it might have been important, it is very nice to be able to look inside it and see something indicating what it's about. For example, you could have something at the start which indicates "Data file for swimming statistics thingy, version 1.5".
Nov 12 '06 #3

Expert 5K+
P: 8,434
I have split gunw's message off to its own thread.
Sep 19 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.