File ›› Set_File_Pointer

プログラム言語 FreeBasic


Set_File_Pointer

構文

Set_File_Pointer(Handle, Position, [Method=file_current])

sub Set_File_Pointer(ByVal fileHandle As HANDLE,ByVal Pos As Integer, ByVal flag As Integer=1)

説明

ファイル内の新しい位置に、ポインタを設定します。

オプション

Handle - ファイル・ハンドル

Position - 新しい位置(マイナス記号の場合は前に戻り、そうでなければ先に進む)

method - メソッドを指定できます。

FILE_BEGIN - 先頭から数える

FILE_CURRENT - 現在の位置から数える

FILE_END - 終わりから数える

プラットホーム

Windows , Linux


#Include "window9.bi"

Var handle=Create_File("Example.txt")

If handle <> Cast(Any Ptr , -1) Then
   Write_StringN(handle,"FreeBasic")
   Write_StringN(handle,"-good")
   Write_StringN(handle," programming language")
   Close_file(handle)
EndIf

handle=Read_file("Example.txt")

If handle <> Cast(Any Ptr , -1) Then
   ? Read_string(handle)
   ? Get_File_Pointer(Handle)
   Set_File_Pointer(Handle,-Get_File_Pointer(Handle) )
   ? Read_string(handle);
   ? Read_string(handle);
   ? Read_string(handle)
   Close_file(handle)
EndIf

Sleep

結果

FreeBasic
11
FreeBasic-good programming language


旧例:

#Include "window9.bi"

Var handle=Create_File("例.txt")
If handle Then
  Write_StringN(handle,"FreeBasic")
  Write_StringN(handle,"-good")
  Write_StringN(handle," programming language")
EndIf
Close_file(handle)
handle=Read_file("例.txt")
If handle Then

  ? Read_string(handle)
  ? Get_File_Pointer(Handle)
  Set_File_Pointer(Handle,-Get_File_Pointer(Handle) )
  ? Read_string(handle);
  ? Read_string(handle);
  ? Read_string(handle)
EndIf
Close_file(handle)
sleep


http://mneniya.ucoz.ru/

←リンク元に戻る Window9 トップに戻る FreeBASIC マニュアル トップに戻る
ロシア語オリジナル:https://users.freebasic-portal.de/freebasicru/window9lib/window9.html