BUFTOFILE

Concept Link IconSee also Concept Link IconExample

Create an ASCII file using the contents of a memory buffer.

WebVue support - Yes.

Action Syntax
Create or overwrite 1
Write or append 2

Syntax 1

IntVal = BUFTOFILE(Handle, FileName);

Return type: INTEGER.

Argument

Meaning

Handle

The start of the memory block. Type LONG.

FileName

The name of the file to be created or overwritten. Type STR.

If executed in a WebVue session context this instruction is processed by the computer that hosts the web back end and the file is created on that computer.

Execution

The named file is created using the contents of the specified memory buffer.

If the file already exists, it will be overwritten.

Return:

1 if successful, else 0.

Syntax 2

IntVal = BUFTOFILE(Handle, FileName, BufferMode[, FileMode]);

Return type: INTEGER.

Argument

Meaning

Handle

The start of the memory block. Type LONG.

FileName

The name of the file to be created or appended. Type STR.

If executed in a WebVue session this instruction is processed by the computer that hosts the web back end and the file will be created on that computer.

BufferMode

Always "USEFULL_PART". Type STR.

FileMode

A string indicating the way in which the target file is opened. Type STR.

Execution

Argument

Meaning

FileMode

WRITE or omitted: The file is created and characters from the memory buffer are written to it until the first null character is encountered in the buffer. If the file already exists, it will be overwritten.

APPEND: The file is opened and characters from the memory buffer are appended to the end until the first null character is encountered in the buffer.

Return:

1 if successful, else 0.

The default folder for relative file names is the project folder \TP.

Example

DIM Handle As Long;
Handle = Alloc_Buffer(50);
Put_Buffer (Handle,0, "Hello World");
Buftofile(Handle,"GREET.TXT");
Free_Buffer(Handle);

For further examples, select the Example link above.