Re: Writing a character to the beginning of the same file



>>So what is the solution to write a character to the >>beginning of
the
>>file and not affect the existing content.

When you want to add to an existing file, you need to build the
handlers to "move" the existing data in the location where to want to
write the new data, if you want to keep the data which was there.

However, there is a work around you could work with. You could set up a
random access file leaving x amount of bytes open before you start
writing your data. This would leave an empty space before your data
where you would be able to write a character or any data type which
does not run into the pre-existing data.

So, for example, if you wanted to 'insert' a single character into a
files, you would first need to know, would this only happen once, and
if it did happen more then once, would you be replacing the first
character you added.

If it is only going to happen once, or if you would replace the
character. After you create a new file, set the pointer to x amount of
bytes needed for the character, then write your data. When you want to
add the single character, you simply add it to the empty space you left
at the beginning.

.



Relevant Pages

  • Re: Girl Genius - 9/30/2009
    ... I don't see such a character on either ... if there are pages "single character changed" ... been that the image url incorporates a description of the image, ... djheydt at hotmail dot com ...
    (rec.arts.sf.written)
  • Re: replacing text data in a binary file
    ... For a binary file, it really depends on the encoding, which I would try to ... If you start using ReadChar & WriteChar you are back to translating to Text. ... Assuming your file is not EBCDIC & you are not using any extended character ... EBCDIC you still have 1 byte per single character however ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Find and Replace - Changing 1st # only
    ... To enter the UDF, ... Match the character ?$? ... Match a single character that is a ?whitespace character? ... Function ReRepl(str As String, sPat As String, _ ...
    (microsoft.public.excel.misc)
  • Re: File Seeking / Overwriting bytes
    ... just leap to an arbitrary byte position, because a text stream ... may need to translate between internal and external forms, ... supplementary characters, so if you write the single character 'ß', ... byte sequence that represents your single character. ...
    (comp.lang.c)
  • Re: Input/output on the Apple ][
    ... > I would like to do single character output using data stored in the ... I would also like to do single character input, ... The standard routine to output a character is COUT, ... This allows for redirection of output to a slot using the PR#n command, ...
    (comp.sys.apple2)