[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Objects' (#rtl)

TDosStream.Open

Open the file stream

Declaration

Source position: objects.pp line 327

procedure TDosStream.Open(

  OpenMode: Word

); virtual;

Description

If the stream's status is stOK, and the stream is closed then Open re-opens the file stream with mode OpenMode. This call can be used after a Close call.

Errors

If an error occurs when re-opening the file, then Status is set to stOpenError, and the OS error code is stored in ErrorInfo

See also

TStream.Open

  

Open the stream

TDosStream.Close

  

Close the file.

Example

Program ex14;

{ Program to demonstrate the TStream.Close method }

Uses Objects;

Var L : String;
    P : PString;
    S : PDosStream; { Only one with Close implemented. }

begin
  L:='Some constant string';
  S:=New(PDosStream,Init('test.dat',stcreate));
  Writeln ('Writing "',L,'" to stream with handle ',S^.Handle);
  S^.WriteStr(@L);
  S^.Close;
  Writeln ('Closed stream. File handle is ',S^.Handle);
  S^.Open (stOpenRead);
  P:=S^.ReadStr;
  L:=P^;
  DisposeStr(P);
  Writeln ('Read "',L,'" from stream with handle ',S^.Handle);
  S^.Close;
  Dispose (S,Done);
end.

Documentation generated on: Jun 23 2021