Core Function FilePos
From Sputnik Wiki
(Difference between revisions)
(→Return Value) |
(→Example) |
||
Line 26: | Line 26: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $File = FileOpen("MyFile.txt", "w") | + | $File = FileOpen("MyFile.txt", "w"); |
− | If isObj($File, "file") | + | If(isObj($File, "file")) // You could just use isObj($File) however adding the "file" will make sure it is indeed a file |
− | FileAppend( $File, "This is line 1\n" ) | + | { |
− | FileAppend( $File, "This is line 2\n" ) | + | FileAppend( $File, "This is line 1\n" ); |
− | FileAppend( $File, "This is line 3\n" ) | + | FileAppend( $File, "This is line 2\n" ); |
− | $CurLocation = FilePos( $File ) | + | FileAppend( $File, "This is line 3\n" ); |
− | println("The location is: $CurLocation") | + | $CurLocation = FilePos( $File ); |
− | FileClose( $File ) | + | println("The location is: $CurLocation"); |
− | + | FileClose( $File ); | |
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 00:23, 17 November 2011
FilePos( <file> )
Contents |
Description
Get the current POSITION of the File Stream pointer.
Parameters
file
A variable containing the File handle.
Return Value
Success: Returns the File Stream pointer location.
Failure: Returns -1 if error occurs.
Remarks
N/A
Example
$File = FileOpen("MyFile.txt", "w"); If(isObj($File, "file")) // You could just use isObj($File) however adding the "file" will make sure it is indeed a file { FileAppend( $File, "This is line 1\n" ); FileAppend( $File, "This is line 2\n" ); FileAppend( $File, "This is line 3\n" ); $CurLocation = FilePos( $File ); println("The location is: $CurLocation"); FileClose( $File ); }