Core Function FileRead
From Sputnik Wiki
(Difference between revisions)
(→Example) |
(→Example) |
||
Line 33: | Line 33: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
$File = FileOpen("MyFile.txt", "r"); | $File = FileOpen("MyFile.txt", "r"); | ||
− | If( | + | If(isVarObj($File, "file")) |
{ | { | ||
$Str = FileRead($File); | $Str = FileRead($File); | ||
Line 45: | Line 45: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
$File = FileOpen("MyFile.txt", "r"); | $File = FileOpen("MyFile.txt", "r"); | ||
− | If( | + | If(isVarObj($File, "file")) |
{ | { | ||
FileSeek($File, 7, "b"); | FileSeek($File, 7, "b"); |
Revision as of 14:37, 19 November 2011
FileRead( <file>, <expression> )
Contents |
Description
Read a number of characters from a previously opened text file starting from current File Steam pointer location.
Parameters
file
A variable containing the File handle.
expression
Optional; Number of letters to read.
If this param is not provided it will read to the end of the file.
Return Value
Success: Returns a string
Failure: Returns 0 if error occurs.
Remarks
N/A
Example
$File = FileOpen("MyFile.txt", "r"); If(isVarObj($File, "file")) { $Str = FileRead($File); println( "String is: " . $Str ); FileClose( $File ); }
You could also tell it where to begin from example :
$File = FileOpen("MyFile.txt", "r"); If(isVarObj($File, "file")) { FileSeek($File, 7, "b"); $Str = FileRead($File); println( "String is: " . $Str ); FileClose( $File ); }