TextEOF Function

Purpose

Tests for end-of-file.

Syntax

? = TextEOF( #n )

n:iexp

Description

Like EOF() this function returns True when the end of file is reached. In addition, this function returns True when the next byte in the stream has value #26 (Control-Z).

TextEOF is required for text files in internal resource files, those files that are included in the source code and which name begins with ":").

Example

The long way of doing it.

// Create dummy file

Local a$, a1$ = "This is record 1", a2$ = "This is a dummy file", a3$ = #26"This part won't be copied"

Open App.Path & "Dummy.Txt" for Binary As # 1

Print # 1; a1$

Print # 1; a2$

'Print # 1; a3$

Seek # 1, 0

// Copy file up to #26

Open App.Path & "Dummy.Tx2" for Output As # 2

While Not EOF(# 1)

Line Input # 1, a$

If EOF(# 1)

Exit If Left(a$, 1) = #26

If InStr(a$, #26) <> 0

a$ = Left$(a$, InStr(a$, #26) - 1)

EndIf

EndIf

Trace a$

Print # 2, a$

Wend

Close # 1 : Close # 2

// Tidy Up

Kill App.Path & "Dummy.Txt"

Kill App.Path & "Dummy.Tx2"

Now with TextEOF...

// Create dummy file

Local a$, a1$ = "This is record 1", a2$ = "This is a dummy file", a3$ = #26"This part won't be copied"

Open App.Path & "Dummy.Txt" for Binary As # 1

Print # 1; a1$

Print # 1; a2$

Print # 1; a3$

Seek # 1, 0

// Copy file up to #26

Open App.Path & "Dummy.Tx2" for Output As # 2

While Not TextEOF(# 1)

Line Input # 1, a$

Trace a$

Print # 2, a$

Wend

Close # 1

Close # 2

Remarks

Input and Line Input test for a TextEOF as well.

See Also

Eof, Loc, Lof, RecordLOF

{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}