mrubik
13th June 2005, 21:14
Hi,
I would like to know which command I can use to update a file,
becouse I'm using seq.puts and seq.write but is creating a new line.
Thank's
Marcos
lbencic
13th June 2005, 21:31
I have not tried to do this, was hoping someone else had a sample for you. How have you written it? I would think the pointer would determine where in the file the seq.write writes to. Have you tried opening with 'w+' instead of 'a+'? This is supposed to start the pointer at the top of the file (a starts at the bottom). And where does it put the line?
NPRao
13th June 2005, 21:56
Marcos,
The programmer's manual has all the information for seq.open() and it depends on which mode you are opening the file.
openmode
The mode in which the file must be opened. This can be one of the following options:
"r" Open for reading. The current file position is placed at the start of the file.
"w" Open for writing. The file is created if it does not already exist. The current file position is placed at the start of the file.
"a" Open for writing. The file is created if it does not already exist. The current file position is placed at the end of the file.
The file position is placed at end of the file before every write statement, even if the previous file action was a seq.seek().
"x" Open for writing. This is the same as "w", except that the function fails if the file already exists.
"r+" Same as "r", but the file can also be written to.
"w+" Same as "w", but the file can also be read.
"a+" Same as "a", but the file can also be read.
"x+" Same as "x", but the file can also be read.
Use the following modes to indicate whether the file is a binary or a text file. You can combine one of these modes with any one of the previous modes (for example, "rt+").
"b" Use for binary files. This is the default mode and need not be specified.
"t" The line separator(s) for text-files are different on Windows NT and UNIX systems. CRLF on the former; LF only on the latter. In addition, a Windows NT text file can include an EOF-character (^Z) that indicates the end of the file. This character should not be returned to a program reading the file.
So, you must specify the "t" option when reading from or writing to a text file on Windows NT systems (for example, "at+".) This ensures that line separators and EOF characters are handled correctly. Never use the "t" option when opening a binary file; on Windows NT systems this will corrupt the file data. The "t" option has no effect on UNIX systems.
Post your code for others to review it.
mark_h
14th June 2005, 14:18
It seems my other post dis-appeared. This thread (http://www.baanboard.com/baanboard/showthread.php?t=10432&highlight=seq.open) should help. It appears that there are some questions still around this topic. So read all of the thread.