Passing file name to procedure.

N

Niv

Guest
Hi all,

I want to pass a file name to a procedure so the
procedure reads all the header blurb and discards it,
terminating when it reaches a defined text sequence,
e.g. "END_OF_HEADER"

This is because I have lots of data tables to read in,
all with different header blurb describing the table
data contents.

Code snippets a follows:

-- Test bench Arcitecture declarative region:

FILE lut_data : TEXT OPEN read_mode IS "D:/lut_data.txt";
FILE tx_data : TEXT OPEN read_mode IS "D:/tx_data.txt";

--------------------------------------------------------
-- Turn this bit into a procedure, calling lut_data file
--------------------------------------------------------
dummy_string := "XXXXXXXXXXXXX";
WHILE (dummy_string /= "END_OF_HEADER") LOOP
readline(lut_data, my_input_line);
read(my_input_line, dummy_string);
END LOOP; -- dummy string.
---------------------------------------------------------
-- This bit extracts the data from the file.
---------------------------------------------------------
WHILE NOT endfile(lut_data) LOOP
FOR lut_index IN 0 TO 5 LOOP
readline(lut_data, my_input_line);
FOR i IN 15 DOWNTO 0 LOOP
hread(my_input_line, read_lut_data); -- hex read.
read_lut(lut_index)(i*8+7 DOWNTO i*8) <= read_lut_data;
END LOOP;
END LOOP;
END LOOP;
--------------------------------------------------------
-- Turn this bit same procedure, but calling tx_data file
--------------------------------------------------------
dummy_string := "XXXXXXXXXXXXX";
WHILE (dummy_string /= "END_OF_HEADER") LOOP
readline(tx_data, my_input_line);
read(my_input_line, dummy_string);
END LOOP; -- dummy string.
---------------------------------------------------------
-- Similarly, read the tx_data file.
---------------------------------------------------------

-- And more files later on, etc, etc.

I've tried to write a PROCEDURE header_discard, that passes lut_data or
tx_data as a variable string, but doesn't compile.

Any ideas please?
 
I've sorted it myself already, so no need to reply,
Thanks anyway.
 
Niv a écrit :

Hi all,

I want to pass a file name to a procedure so the
procedure reads all the header blurb and discards it,
terminating when it reaches a defined text sequence,
e.g. "END_OF_HEADER"

This is because I have lots of data tables to read in,
all with different header blurb describing the table
data contents.

Code snippets a follows:
[...]

I've tried to write a PROCEDURE header_discard, that passes lut_data or
tx_data as a variable string, but doesn't compile.
lu_data and tx_data are not strings but files!

Try something like:
procedure filter (file f:text)
is
....

JD.
 
Niv wrote:
I've sorted it myself already, so no need to reply,
Are you going to share the solution
or leave us suspended?

-- Mike Treseler
 

Welcome to EDABoard.com

Sponsor

Back
Top