* [Q] Ada.Text_IO.Is_Open query
@ 1996-07-03 0:00 John McCabe
1996-07-06 0:00 ` Laurent Guerby
1996-07-06 0:00 ` John Herro
0 siblings, 2 replies; 3+ messages in thread
From: John McCabe @ 1996-07-03 0:00 UTC (permalink / raw)
If I have defined an object of Ada.Text_IO.File_Type, say My_File, I
can use Ada.Text_IO.Is_Open to find out whether My_File is associated
with a physical file.
However, if I have a string say "autoexec.bat", is there a function
that will tell me if I have a file already open of that name (i.e. if
the physical file is associated with an object of type
Ada.Text_IO.File_Type - effectively the opposite of what
Ada.Text_IO.Is_Open does)?
I'd be grateful for any pointers, I originally thought that
Ada.Text_IO.Is_Open would do what I want until I got an error on
compilation, when I decided I should look at the RM! (don't have a lot
of text_io used on satellite instruments where I work)
I couldn't find what I wanted but maybe I was looking in the wrong
place!
Best Regards
John McCabe <john@assen.demon.co.uk>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Q] Ada.Text_IO.Is_Open query
1996-07-03 0:00 [Q] Ada.Text_IO.Is_Open query John McCabe
@ 1996-07-06 0:00 ` Laurent Guerby
1996-07-06 0:00 ` John Herro
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Guerby @ 1996-07-06 0:00 UTC (permalink / raw)
John> If I have defined an object of Ada.Text_IO.File_Type, say
John> My_File, I can use Ada.Text_IO.Is_Open to find out whether
John> My_File is associated with a physical file.
John> However, if I have a string say "autoexec.bat", is there a
John> function that will tell me if I have a file already open of that
John> name (i.e. if the physical file is associated with an object of
John> type Ada.Text_IO.File_Type - effectively the opposite of what
John> Ada.Text_IO.Is_Open does)?
Assuming that you have a way to step through all your application
objects of type File_Type, you can get the name of the associated
physical file for each one using the function Ada.Text_IO.Name which
returns a string that "may be used in an open Operation",
RM95-A.8.2(21), so you should get the full name (with complete
path). You may need a bit of file name processing to be able to
compare with "autoexec.bat".
Hope this helps,
--
Laurent Guerby <guerby@gnat.com>, Team Ada.
"Use the Source, Luke. The Source will be with you, always (GPL)."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Q] Ada.Text_IO.Is_Open query
1996-07-03 0:00 [Q] Ada.Text_IO.Is_Open query John McCabe
1996-07-06 0:00 ` Laurent Guerby
@ 1996-07-06 0:00 ` John Herro
1 sibling, 0 replies; 3+ messages in thread
From: John Herro @ 1996-07-06 0:00 UTC (permalink / raw)
john@assen.demon.co.uk (John McCabe) writes:
> If I have a string say "autoexec.bat", is there a function that
> will tell me if I have a file already open of that name ...
> effectively the opposite of what Ada.Text_IO.Is_Open does?
Dear John,
I don't know of such a function, but I can suggest the following.
Instead of calling Ada.Text_IO.Create and Ada.Text_IO.Open directly, call
procedures that you write. Your procedures should first store the file
name, say in a linked list of unbounded strings, and then call
Ada.Text_IO.Create or Ada.Text_IO.Open. Then write a function to see if a
given string is in the linked list. (You'll also need a procedure to call
in place of Ada.Text_IO.Close. Your procedure should call
Ada.Text_IO.Name to get the file name, remove the string from the linked
list, and then call Ada.Text_IO.Close.)
This isn't exactly what you asked for, but it doesn't sound like much
work.
I know from reading c.l.a. that you're a very advanced Ada person, so
please forgive me if you thought of this already, and were asking only in
the hope of finding a simpler answer.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1996-07-06 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-03 0:00 [Q] Ada.Text_IO.Is_Open query John McCabe
1996-07-06 0:00 ` Laurent Guerby
1996-07-06 0:00 ` John Herro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox