Filing 
Author Message
 Filing

Is there a way to write to a specific line in a file, as well as read from a
specific line in a file.

What I am interested in doing is setting up a utility program for another
program that controls settings. Eg: name list in a CComboBox. I need for the
utility program to fill this list and for the user program to load this list
at start up. I figured if I could set ranges like line 1 - 100 (names), line
101 -200(strings of something), line 201-300(blah, blah). Then in the user
program, have a loop filling 1 comboBox with lines 1-100, another with lines
101-200, etc etc at init. time.

Any direction, help, examples would be greatly appreciated!
Mike



Sat, 02 Aug 2003 05:00:33 GMT  
 Filing

Quote:

> Is there a way to write to a specific line in a file, as well as read from a
> specific line in a file.

> What I am interested in doing is setting up a utility program for another
> program that controls settings. Eg: name list in a CComboBox. I need for the
> utility program to fill this list and for the user program to load this list
> at start up. I figured if I could set ranges like line 1 - 100 (names), line
> 101 -200(strings of something), line 201-300(blah, blah). Then in the user
> program, have a loop filling 1 comboBox with lines 1-100, another with lines
> 101-200, etc etc at init. time.

> Any direction, help, examples would be greatly appreciated!
> Mike

The CFile::Seek function lets you move to a desired byte offset within a file,
then the next read or write will begin at that spot.  To do what you want you
will first have to initialize the file so that all its "lines" are a fixed size
because you can't replace a 10-byte line with a 20-byte line within the file.

--
Scott McPhillips [VC++ MVP]



Sat, 02 Aug 2003 07:49:50 GMT  
 Filing
Sorry to ask, but how do I initialize the file so that its lines are a fixed
size?
I don't know where to begin so just a nudge in the right direction would be
helpful!
Mike


Quote:

> > Is there a way to write to a specific line in a file, as well as read
from a
> > specific line in a file.

> > What I am interested in doing is setting up a utility program for
another
> > program that controls settings. Eg: name list in a CComboBox. I need for
the
> > utility program to fill this list and for the user program to load this
list
> > at start up. I figured if I could set ranges like line 1 - 100 (names),
line
> > 101 -200(strings of something), line 201-300(blah, blah). Then in the
user
> > program, have a loop filling 1 comboBox with lines 1-100, another with
lines
> > 101-200, etc etc at init. time.

> > Any direction, help, examples would be greatly appreciated!
> > Mike

> The CFile::Seek function lets you move to a desired byte offset within a
file,
> then the next read or write will begin at that spot.  To do what you want
you
> will first have to initialize the file so that all its "lines" are a fixed
size
> because you can't replace a 10-byte line with a 20-byte line within the
file.

> --
> Scott McPhillips [VC++ MVP]



Sat, 02 Aug 2003 20:43:45 GMT  
 Filing
You just write a bunch of fixed-length lines to the file!  They can be full of
spaces or nulls, whatever.  The point is to make space in the file for every
possible line so you can then seek to any position and overwrite any particular
line.  The length of each line has to be at least as big as the longest possible
overwrite so the overwrite won't mess up the following line.

Quote:

> Sorry to ask, but how do I initialize the file so that its lines are a fixed
> size?
> I don't know where to begin so just a nudge in the right direction would be
> helpful!
> Mike




> > > Is there a way to write to a specific line in a file, as well as read
> from a
> > > specific line in a file.

> > > What I am interested in doing is setting up a utility program for
> another
> > > program that controls settings. Eg: name list in a CComboBox. I need for
> the
> > > utility program to fill this list and for the user program to load this
> list
> > > at start up. I figured if I could set ranges like line 1 - 100 (names),
> line
> > > 101 -200(strings of something), line 201-300(blah, blah). Then in the
> user
> > > program, have a loop filling 1 comboBox with lines 1-100, another with
> lines
> > > 101-200, etc etc at init. time.

> > > Any direction, help, examples would be greatly appreciated!
> > > Mike

> > The CFile::Seek function lets you move to a desired byte offset within a
> file,
> > then the next read or write will begin at that spot.  To do what you want
> you
> > will first have to initialize the file so that all its "lines" are a fixed
> size
> > because you can't replace a 10-byte line with a 20-byte line within the
> file.

> > --
> > Scott McPhillips [VC++ MVP]

--
Scott McPhillips [VC++ MVP]


Sat, 02 Aug 2003 23:46:02 GMT  
 Filing
Thanks Scott


Quote:
> You just write a bunch of fixed-length lines to the file!  They can be
full of
> spaces or nulls, whatever.  The point is to make space in the file for
every
> possible line so you can then seek to any position and overwrite any
particular
> line.  The length of each line has to be at least as big as the longest
possible
> overwrite so the overwrite won't mess up the following line.


> > Sorry to ask, but how do I initialize the file so that its lines are a
fixed
> > size?
> > I don't know where to begin so just a nudge in the right direction would
be
> > helpful!
> > Mike




> > > > Is there a way to write to a specific line in a file, as well as
read
> > from a
> > > > specific line in a file.

> > > > What I am interested in doing is setting up a utility program for
> > another
> > > > program that controls settings. Eg: name list in a CComboBox. I need
for
> > the
> > > > utility program to fill this list and for the user program to load
this
> > list
> > > > at start up. I figured if I could set ranges like line 1 - 100
(names),
> > line
> > > > 101 -200(strings of something), line 201-300(blah, blah). Then in
the
> > user
> > > > program, have a loop filling 1 comboBox with lines 1-100, another
with
> > lines
> > > > 101-200, etc etc at init. time.

> > > > Any direction, help, examples would be greatly appreciated!
> > > > Mike

> > > The CFile::Seek function lets you move to a desired byte offset within
a
> > file,
> > > then the next read or write will begin at that spot.  To do what you
want
> > you
> > > will first have to initialize the file so that all its "lines" are a
fixed
> > size
> > > because you can't replace a 10-byte line with a 20-byte line within
the
> > file.

> > > --
> > > Scott McPhillips [VC++ MVP]

> --
> Scott McPhillips [VC++ MVP]



Tue, 05 Aug 2003 09:17:20 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. putting end of file character in binary file (cutting the file short)

2. FILE(0), FILE(1), FILE(2) .....

3. HOW TO Filter Files Without File Extention in Open File Dialog Box

4. File extension filtering for the file dialog presented for file opening

5. Play WAV File From Resource File

6. Newbie: separate big .cs file into small .cs files

7. File Sharing Bug(?) in File.OpenText

8. How to write rtf file of a word file using VC++

9. How to download results file from form post (In IE it generates a save file dialog)

10. write a file to a xml file

11. fatal error C1083: Cannot open include file: 'excpt.h': No such file or directory

12. File.Move File.Delete

 

 
Powered by phpBB® Forum Software