FGETS

Concept Link IconSee also

Read a character string from a file.

WebVue support - Yes.

Before using any of the file management instructions, except FSTAT, RENAME, UNLINK, FILETOBUF or BUFTOFILE, you must first open the file using an FOPEN instruction.

Before any program including the FOPEN instruction ends, it must execute an FCLOSE instruction.

Syntax

StrVal = FGETS(Filename, Num);

Return type: STR.

Argument

Meaning

Filename

The name of the file from which the string is to be read. Type STR.
If executed in a WebVue session context this instruction is processed by the computer that hosts the web back end and the referenced file is on that computer.

Num

The number of characters to be read. Any numeric type.

Execution

StrVal

The specified number of characters is read and returned in a string.

If the end of the file is reached before the number of characters is retrieved, or a Line Feed character is found, the return string will be truncated accordingly. The file pointer is advanced by the number of characters read.

Example

str1 = FGETS("HELP.TXT",20);