Thread Subject: Write to file

Subject: Write to file

From: Carvalho

Date: 11 Apr, 2007 16:28:42

Message: 1 of 4

I need to change a txt file but when i use the fortran Write command
to change it, the rest of the file content is erased. I can i change
a txt file without erasing the rest of the file?

Tanks...

Subject: Write to file

From: nospam@see.signature (Richard Maine)

Date: 11 Apr, 2007 16:35:12

Message: 2 of 4

Carvalho <jfscarvalho@gmail.com> wrote:

> I need to change a txt file but when i use the fortran Write command
> to change it, the rest of the file content is erased. I can i change
> a txt file without erasing the rest of the file?

Basically, no. That's the way sequential files work. In that statement
does lie one hint. You can do things like that with a direct access
file. However, normal text files aren't direct access. It is sometmes
possible to do low-level tricks to use direct access to write on a
normal text file, but that requires understanding of exactly what is
going on at a system-dependent level.

Usually, the most practical way to do things like that is to copy the
file, making the modifications during the copy process.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

Subject: Write to file

From: Terence

Date: 11 Apr, 2007 22:41:04

Message: 3 of 4

Since its a text file, you can use any one of very many text editors.
The copying and saving is all done "behind the scenes" with temporary
files you don't have to know anything about.

Some editors are limited to some large maximum file size.
Some are essentially limited to some very large maximum line length
(meaning you may not know where you are if you pass 999 characters in
one line).

Most (probably all) text editors are only usable if there are carriage-
return or new-line codes (or preferably both) to separate the lines of
text.

Try the EDIT command on your computer (DOS) or Notepad (in Windows).

I prefer Wordstar myself, or VEDIT.
Very many are free or at least shareware.

Subject: Write to file

From: Terence

Date: 11 Apr, 2007 22:45:56

Message: 4 of 4

Oh!, Wordstar and Edit both work with Spanish and Portugese as well as
English, but Wordstar adds extra codes around any special character
like accented vowels or in general any upper-half-ascii table symbols.
Edit does not have this "problem" but works with smaller maximum file
sizes.
Notpad will fail with some upper-table symbols, distorting the file.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com