Does writeline consume the line?

Guest
The general process for writing to a file involves a write to a
line, followed by a writeline to a file. But does the writeline
consume the contents of the line?

I think it does. I'm doing a multi-channel filter simulation.
I'm writing the line to a Results.txt file if the channel is the
active channel; then I'm writing the same line to one of eight
Results<n>.txt files according to the channel number. I was
surprised to see that Results0.txt is empty when the active
channel is channel 0. I infer that this means that writeline
to the active channel consumes the contents of the line so that
there is nothing left to write to Results0.txt.

Dave
 
On 09/12/14 16:39, davehigton14@gmail.com wrote:
The general process for writing to a file involves a write to a
line, followed by a writeline to a file. But does the writeline
consume the contents of the line?

I think it does. I'm doing a multi-channel filter simulation.
I'm writing the line to a Results.txt file if the channel is the
active channel; then I'm writing the same line to one of eight
Results<n>.txt files according to the channel number. I was
surprised to see that Results0.txt is empty when the active
channel is channel 0. I infer that this means that writeline
to the active channel consumes the contents of the line so that
there is nothing left to write to Results0.txt.

Dave

Yes, writeline empties the line buffer.

You can make a copy of the buffer if you know/realise that it is access
string, e.g.

process
variable L1 : line;
variable l2:: line;

begin

write(L1, fred);
L2 := new string'(L1.all);
writeline(F, L1);
writeline(F2, L2);

regards
Alan



--
Alan Fitch
 
On Tuesday, December 9, 2014 11:46:41 PM UTC, Alan Fitch wrote:

On 09/12/14 16:39, Dave Higton wrote:

The general process for writing to a file involves a write to a
line, followed by a writeline to a file. But does the writeline
consume the contents of the line?

I think it does. I'm doing a multi-channel filter simulation.
I'm writing the line to a Results.txt file if the channel is the
active channel; then I'm writing the same line to one of eight
Results<n>.txt files according to the channel number. I was
surprised to see that Results0.txt is empty when the active
channel is channel 0. I infer that this means that writeline
to the active channel consumes the contents of the line so that
there is nothing left to write to Results0.txt.

Dave


Yes, writeline empties the line buffer.

You can make a copy of the buffer if you know/realise that it is access
string, e.g.

process
variable L1 : line;
variable l2:: line;

begin

write(L1, fred);
L2 := new string'(L1.all);
writeline(F, L1);
writeline(F2, L2);

Thanks, Alan, for the confirmation, and for the simple solution.

Dave
 

Welcome to EDABoard.com

Sponsor

Back
Top