Core Function FileOpenText

From Sputnik Wiki
Jump to: navigation, search
FileOpenText( <filename> )

Contents

Description

Opens a file for reading only (text files only) .

Parameters

filename

Name of the text file to open.

Return Value

Success: Returns a text file "handle" for use with subsequent file functions

Failure: Returns null if error occurs.

Remarks

This does NOT return the same "handle" used by FileOpen() so you cannot use it in the same places as that however the following functions do support the handled returned from FileOpenText().

FilePos(), FileSeek(), FileReadText()

Example

// Open the file and return the handle
my $f = FileOpenText("Main.spk");
if ($f)
{
	// Read the first line
	say FileReadText($f, 'l');
	// Read the second line
	say FileReadText($f, 'l');
	// Read a char
	say FileReadText($f, 'c');
	// Read a 8 char
	say FileReadText($f, 'c', 8);
	// Read to the end of the file
	say FileReadText($f, 'e');
}
// free the handle
FileClose($f);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox