If you have a ListBox with allot of lists, then is there an easy way to save each line to an already existing file and overwrite previousle lines in the file?
[tab]Are you wanting to replace the entire file out or just replace the same line in the file with the line from the ListBox? For example, if you open the file for writing the file will be replaced if it already exists. You can the write the entire ListBox to the file again.
[tab]If you want to replace only one line in the file, you will have to open the file in "sequential" mode, find the line you want to replace, and overwrite it with the correct line from the ListBox.
[tab]The first way is easiest but if the ListBox is very large then it is not the fastest way. The second requires a little more programming and forethought, but it would be fastest for large amounts of data.
[tab]Which is the way you want to go?
[sig]<p>James P. Cottingham<br><a href=mailto: > </a><br><a href=
The purpose that would suit the program I’m writing would be the first, to overwrite entire file. However, it would be nice if you could give me an example of the second as well! (it is not important) [sig][/sig]
[tab]I'll get you an example as soon as my workload drops below the [red]critical[/red] level. I won't forget to do this but right now I can't do much more than chat. I'll be back. B-(
[sig]<p>James P. Cottingham<br><a href=mailto: > </a><br><a href=
[tab]I haven't forgotten about you but I'm still very tied up so I'll give you some commands and let you experiment. C has the commands fpos_t, fgetpost, fsetpos. C++ streams has streampos, tellg, tellp, seekg, and seekp. BCB has FileWrite, FileSeek, and FileRead. Each command is similar and does similar things. Personally, I prefer the standard C++ commands.
[tab]I was hoping to show you some code but I still don't have time so I just describe the procress. You can create a file with a fixed-length record (e.g. fwrite), then write the records to the file (using one of the commands above). When you need a record, you can seek for the proper record, and then read that record in. If you need to replace that record you can write to the same place in the file.
[tab]Your best bet is to look up these commands in the help file or a C or C++ book. You can then work through their examples. Sorry I couldn't be of more help but I'm swamped and I don't use these functions very much.
[tab]BTW, I'd recommend C & C++ Code Capsules by Chuck Allison.
[sig]<p>James P. Cottingham<br><a href=mailto: > </a><br><a href=
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.