Writes the arguments out to the stream and terminates them with the end of line characters. The method puts a space between every argument so that they may be properly parsed later.
To write out a group of arguments unterminated, use the
WriteArgs method.
Namespace: GStreams
Delphi
|
public
procedure WriteLn(Args: array of const);
|
Parameters
Args
Type: array of const
The following example writes out some information and then reads it back. Note that without spaces or other delimiters between Puts the Get method calls would not work. The Get method calls need delimiters; methods like PutLine, which automatically writes end of line delimiters, or WriteLn, which writes spaces between the fields, ensure the correct reading behavior:
Delphi
|
var
FileStream: TGTextStream;
begin
if (SaveDialog.FileName <> '') or SaveDialog.Execute then
begin
FileStream := TGTextStream.Create( SaveDialog.Filename, fmCreate );
try
FileStream.PutLine( eFirstName.Text );
FileStream.PutLine( eLastName.Text );
FileStream.WriteLn( [seAge.Value, rgMaritalStatus.ItemIndex] );
FileStream.PutLine( eLastEmployer.Text );
FileStream.WriteLn( [seYearsAtJob.Value, seNumJobs.Value,
cbJobTitle.ItemIndex, rgDelphiKnowledge.ItemIndex, rgDatabaseKnowledge.ItemIndex, rgComponentKnowledge.ItemIndex, rgGraphicsKnowledge.ItemIndex] );
finally
FileStream.Free;
end;
OpenDialog.FileName := SaveDialog.FileName;
end;
end;
var
FileStream: TGTextStream;
begin
if OpenDialog.Execute then
begin
FileStream := TGTextStream.Create( OpenDialog.Filename, fmOpenRead );
try
eFirstName.Text := FileStream.GetLine;
eLastName.Text := FileStream.GetLine;
seAge.Value := FileStream.GetInteger;
rgMaritalStatus.ItemIndex := FileStream.GetInteger;
FileStream.SkipSpaces;
eLastEmployer.Text := FileStream.GetLine;
seYearsAtJob.Value := FileStream.GetInteger;
seNumJobs.Value := FileStream.GetInteger;
cbJobTitle.ItemIndex := FileStream.GetInteger;
rgDelphiKnowledge.ItemIndex := FileStream.GetInteger;
rgDatabaseKnowledge.ItemIndex := FileStream.GetInteger;
rgComponentKnowledge.ItemIndex := FileStream.GetInteger;
rgGraphicsKnowledge.ItemIndex := FileStream.GetInteger;
mmApplicant.Lines.Clear;
eJobOffer.Text := '';
eStartingSalary.Text := '';
finally
FileStream.Free;
end;
SaveDialog.FileName := OpenDialog.Filename;
end;
end;
|
|