467,161 Members | 912 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

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

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
  • viewed: 7514
Share:
3 Replies
1GB
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 8TB
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 8TB
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.

Similar topics

3 posts views Thread by Jack Harrington | last post: by
4 posts views Thread by Vishal | last post: by
3 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.