From: bishopm@source.asset.com (Michael M. Bishop)
Subject: Re: newbie binary file I/O question
Date: 14 Mar 1995 11:18:42 -0500
Date: 1995-03-14T11:18:42-05:00 [thread overview]
Message-ID: <3k4fl2$j45@source.asset.com> (raw)
In-Reply-To: D4vHw0.LB@nvl.army.mil
In article <D4vHw0.LB@nvl.army.mil>, Dolores Shaffer <shaffer@oliver> wrote:
>procedure nextstep is
>
>Package byte_io is new sequential_io(intbyte);
>
>din_file: byte_io.file_type;
>value:intbyte;
>name_of_file: string(1..80);
>name_length : natural;
>
>begin
> text_io.put_line("enter name of file to open");
> text_io.get_line(name_of_file,name_length);
>
> byte_io.open(din_file, byte_io.file_mode'first, name=>name_of_file);
>--IT BOMBS HERE!!
>--but byte_io.open(din_file, byte_io.file_mode'first, "filename"); works
You might want to try this:
byte_io.open (din_file, byte_io.file_mode'first,
name => name_of_file(1 .. name_length));
What is probably happening in the code that raises name_error is that
the slice name_of_file(name_length + 1 .. name_of_file'last) (i.e., the
part of name_of_file that wasn't filled in by get_line) has some junk
characters in it and the OS is thinking that those junk characters
constitute part of the file name. So the slice name_of_file(1 ..
name_length) references only that part of name_of_file that the user
entered.
Hope this works...
--
| Mike Bishop | The opinions expressed here reflect |
| bishopm@source.asset.com | those of this station, its management, |
| Member: Team Ada | and the entire world. |
prev parent reply other threads:[~1995-03-14 16:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-03-03 16:31 newbie binary file I/O question Dolores Shaffer
1995-03-04 16:01 ` Tore Joergensen
1995-03-05 23:04 ` Keith Thompson
1995-03-14 16:18 ` Michael M. Bishop [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox