Write a memo field or character string to a text file on disk
HB_MEMOWRIT( <cFileName>, <cString>, [<lWriteEof>] ) --> lSuccess
<cFileName> is the filename to read from disk. It must include the file extension. If file to be read lives in another directory, you must include the path.
<cString> Is the memo field or character string, to be write to <cFile>.
<lWriteEof> Is a logic variable that settle if the “end of file” character – CHR(26) – is written to disk. This parameter is optional. By default is true (.T.)
Function returns true (.T.) if the writing operation was successful; otherwise, it returns false (.F.).
This a function that writes a memo field or character string to a text file on disk (floppy, HD, CD-ROM, etc.) If you not specified a path, HB_MEMOWRIT() writes <cFileName> to the current directory. If <cFileName> exists, it is overwritten.
There is a third parameter (optional), <lWriteEof>, (not found in CA-Cl*pper) which let to programmer change the default behavior of – always – to write the EOF character, CHR(26) as in CA-Cl*pper.
If there is no third parameter, nothing change, EOF is written as in CA-Cl*pper, the same occurs when <lWriteEof> is set to .T. But, if <lWriteEof> is set to .F., EOF char is Not written to the end of the file.
HB_MEMOWRIT() function is used together with HB_MEMOREAD() and MEMOEDIT() to save to disk text from several sources that was edited, searched, replaced, displayed, etc.
Note that HB_MEMOWRIT() do not use the directory settings SET DEFAULT.
HB_MEMOWRIT() vs MEMOWRIT(): HB_MEMOWRIT() never writes the obsolete EOF char at the end of the file.
* This example uses HB_MEMOWRIT() to write the contents of a character * variable to a text file. cFile := "account.prg" cString := HB_MEMOREAD( cFile ) cCopyright := "Melina" IF At( "Melina", cString ) == 0 // check for copyright HB_MEMOWRIT( cFile, cCopyright + cString ) // if not, add it! ENDIF
Library is rtl
MEMOEDIT(), MEMOREAD(), HB_MEMOWRIT()