xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

MemoWrit()

Writes a character string or a memo field to a file.

Syntax

MemoWrit( <cFileName>, <cString> ) --> lSuccess

Arguments

<cFileName>
This is a character string holding the name of the file to create. It must include path and file extension. If the path is omitted from <cFileName>, the file is created in the current directory.
<cString>
A character string to be written to the file <cFileName>.

Return

The function returns .T. (true) when the string <cString> could be written to the file <cFileName>, otherwise .F. (false) is returned.

Description

MemoWrit() creates a file, writes the character string <cString> to it, and closes the file. If the file exists already, it is overwritten without warning. When the file cannot be created, the return value is .F. (false).

Note:  the function writes an end-of-file marker (Chr(26)) to the created file. That means, the file created by MemoWrit() contains one byte more than the input string <cString>. This must be taken into consideration if the file is later read using MemoRead().

Info

See also:FCreate(), FWrite(), MemoEdit(), MemoRead()
Category: Character functions , Memo functions
Source:rtl\memofile.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example contains the shortest possible source code of
// a complete text file editor (8 lines of code).

   PROCEDURE Main( cFileName )
      IF Empty( cFileName )
         ? "No file name specified"
         QUIT
      ENDIF

      MemoWrit( cFileName, MemoEdit( MemoRead( cFilename ) ) )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe