problems with readline function within a subprogram

E

ed.agunos

All,

I am having problems with the readline function within a subprogram.

Check out the following processes. In the first process
"proc_wo_subprogram", everything works correctly. The next line from
the file is read and the pointer is assigned to "data_line" and I can
access the object that "data_line" points to. But in the second process
"proc_w_subrprogram", I can't access the object and I don't really
understand why. Can any one explain?

proc_wo_subprogram : process
variable stat : file_open_status;
file data_file : text;
variable data_line : line;
begin
file_open(stat, data_file, "test_data.dat", read_mode);
readline(data_file, data_line);
file_close(data_file);
wait;
end process;

proc_w_subprogram : process

procedure go is
variable stat : file_open_status;
file data_file : text;
variable data_line : line;
begin
file_open(stat, data_file, "test_data.dat", read_mode);
readline(data_file, data_line);
file_close(data_file);
end procedure;

begin
go;
wait;
end process;
 
P

Paul Uiterlinden

All,

I am having problems with the readline function within a subprogram.

Check out the following processes. In the first process
"proc_wo_subprogram", everything works correctly. The next line from
the file is read and the pointer is assigned to "data_line" and I
can access the object that "data_line" points to. But in the second
process "proc_w_subrprogram", I can't access the object and I don't
really understand why. Can any one explain?

proc_wo_subprogram : process
variable stat : file_open_status;
file data_file : text;
variable data_line : line;
begin
file_open(stat, data_file, "test_data.dat", read_mode);
readline(data_file, data_line);
file_close(data_file);
wait;
end process;

proc_w_subprogram : process

procedure go is
variable stat : file_open_status;
file data_file : text;
variable data_line : line;
begin
file_open(stat, data_file, "test_data.dat", read_mode);
readline(data_file, data_line);
file_close(data_file);
end procedure;

begin
go;
wait;
end process;

I don't get it. What do you mean with "can't access". Are there any
error messages?

Of course you realize the variables of the procedure cannot be
accessed in the proc_w_subprogram process, don't you? The variables
are local to the procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top