open()
Scott
scott.filepro at aanet.com.au
Wed Mar 5 16:28:52 PST 2014
Hi all
Can anyone please explain the use of open () or create() with the
writeline() commands please.
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
::'FILEPRO TO MYSQL DUMP:
::co (1,.0,g); cx (8,.0) = "1":
:'file fields count:fc (3,.0) = NUMFIELD(-):
::lf = open("c:/fp/output/mysql_dump.txt","rwc"):
:lf lt "0":errorbox " Failed to open file " ; end:
::' now build record data:
::dim fields(49)1:
::sq = "":
loop:cx gt fc:goto out:
:cx eq "1": sq = sq & " INSERT INTO customer ":
:cx eq "1" ' Open Bracket of new record:sq = sq < "("&
"'"{@rn{"',":
::nm = FIELDNAME(-,cx):
: ' field data in quotes:sq = sq &
"'"{fields(cx){"'"{"-"{nm:
:cx ne fc ' comma between fields:sq = sq{",":
:cx eq fc ' Close bracket for last field:sq = sq &
")":
::cx = cx + "1":
::goto loop:
out::' check to see if last record:
:@rp ne @ts:sq = sq {",":
::gosub line:
::aa = close (lf):
::end:
line:' WRITE LINE:'now write a line:
::aa = writeline(lf,sq):
:aa lt "0":show "Failed to write line":
::return:
Thank you
Scott Smith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.celestial.com/pipermail/filepro-list/attachments/20140306/e1d268e4/attachment.html
More information about the Filepro-list
mailing list