I'm trying to read a list of stimulus files from a directory file. This is described on page 527 of Ashenden's book.
At the start of file_loop, read(directory, file_name, file_name_length); doesn't do what I expected. I assumed it would read an individual string representing a file name, and would stop when it came to a or . Then on the next pass of the loop it would read the next filename. Instead, it fills file_name with 50 characters (including and ) on each pass.
What am I doing wrong?
Thanks
file_reader : process is type directory_file is file of string; file directory : directory_file open read_mode is "stimulus-directory"; variable file_name : string(1 to 50); variable file_name_length : natural; variable open_status : file_open_status; variable char : character; type char_file is file of character; -- one byte each file stim_file : char_file; begin file_loop : while not endfile(directory) loop read(directory, file_name, file_name_length); if file_name_length > file_name'length then report "file name too long: " & file_name & "... - file skipped" severity warning; next file_loop; end if; file_open (open_status, stim_file, file_name(1 to file_name_length), read_mode); if open_status /= open_ok then report file_open_status'image(open_status) & " while opening file " & file_name(1 to file_name_length) & " -file skipped" severity warning; next file_loop; end if; stimulus_loop : while not endfile(stim_file) loop if (rst = '1') then sig