open()
Fairlight
fairlite at fairlite.com
Wed Mar 5 19:08:57 PST 2014
On Thu, Mar 06, 2014 at 10:28:52AM +1000, Scott thus spoke:
> Hi all
>
> Can anyone please explain the use of open () or create() with the
>
> LF = open ("path/filename", "rwct")
>
> "filename" is the name of the file to be opened.
> "mode" is the access mode to use (see below).
> "aa" is the file handle.
>
> Parameters
>
> mode r - read access
> w - write access
> c - create if doesn't exist
> 0 - truncate if already exists
> b - binary mode
> t - text mode
>
> & er = writeline(lf,sq)
>
> sq being the sql statement
>
> Then: bytes = WRITELINE(handle,source,length)
> Then: bytes = WRITELINE(handle,source)
>
> "handle" is the file handle returned by OPEN() or CREATE().
> "source" is the data to write.
> "length" is the number of bytes to write.
>
> "bytes" is the number of bytes written, including newline
>
> If length is not specified, the length of the source field is used.
>
> A newline character is appended to the information written.
>
> Return value
>
> The number of bytes written, including the newline.
>
> Note: The file must be opened in text mode. A newline character is appended
> to the information written.
>
> Yet each time a new record is done in the rreport it dumps over previous
> lines/file.
>
> FP Ver 4.8.13 Windows
Your problem is that open() in filePro has many flags, including 't' for
truncate (equivalent to O_TRUNC in the underlying C function open(2)), but
it has no analog for O_APPEND, and O_APPEND is not logically ORed to the
rest of the flags as the default behaviour.
What you really want to do is focus on this:
4.5 SEEK Set the current location within an opened file.
Syntax:
aa = SEEK(handle,offset,whence)
aa = SEEK(handle,offset)
Where handle is the file handle returned by OPEN() or
CREATE(), offset is the position within the file, and
whence flags how to interpret the offset.
Parameters
whence 0 - absolute position in the file
1 - position relative to the current position
2 - position relative to end-of-file
Return value: The resulting absolute position in the file.
Notes: Offset can be negative when using relative positioning.
Right after your open(), do this:
aa=seek(lf,"0","2")
That will set you up to append to the end of the file.
mark->
--
Audio panton, cogito singularis.
More information about the Filepro-list
mailing list