8.5.9 GetTextPosition (return the current read/write position)
- Purpose
-
Returns the current read/write position in a text file.
- Syntax
GetTextPosition (FileId)
- Argument
-
- FileId
-
Specify the file ID as a number or as a variable that stores this value.
This file ID is the execution result returned by the TextOpen command.
- Description
-
The GetTextPosition command acquires the current read/write position in the text file specified by the file ID, as the number of bytes from the beginning of the file (0). The command returns the current read/write position on successful execution, or a zero-length string ("") if an error occurs.
An error results if the read/write start position is beyond 2,147,483,647.
- Example
' Change the string "Start" in the text file "Loging.txt" ' in the execution folder to "Start script execution". Dim file1 file1 = TextOpen ( _BIN_+"Loging.txt" ,ReadWrite ) If file1 = 0 Then MessageBox ( _BIN_+"Failed to open Loging.txt" ,OK ) Else Dim line ,position ,buff For line = 1 To 10 ' Acquire the read/write position. position = GetTextPosition ( file1 ) If TextRead ( file1 ,buff ) Then If buff = "Start" Then ' Overwrite the text at the read/write position. TextWrite ( file1 ,"Start script execution" ,True ,position ) End Else Exit For End Next TextClose (file1) End
- JP1/Script version
-
Supported from JP1/Script 05-00.