The definition of File_Type is “limited private” which does not tell me if I can assign To_string( file_name_unb_str) as a file name.
Annex A and Cohen 2nd ed. shed no light to me on this as part of the daunting complexity of file i/o in Ada.
The definition of File_Type is “limited private” which does not tell me if I can assign To_string( file_name_unb_str) as a file name.
Annex A and Cohen 2nd ed. shed no light to me on this as part of the daunting complexity of file i/o in Ada.
File I/O is very simple. You don’t associate a name with a file, you simply provide that name to the Open and Create subprograms under parameter “Name” and access it while open with accessor function Name. So nothing stops you from opening a file or stream (for stream I/O) with one name, closing it, and opening it again with another name. Elements of filetype are really interchangeable handles, so semantically not tied at all to any particular file or source of input when they’re close.
Thank you for the exact answer, and not found elsewhere in my search of the Ada 95 literature, including Barnes’ Ada2005, such as it is.
The answer was in the code you posted yourself in another thread:
Create( File, Out_file, "filename.txt") ;
Maybe clear to the experienced Ada projammer, but criticism not withstanding to this Ada 95 newbie; hence requiring the instant subject line and content to be posted.
BTW, the code I posted was not original but taken from an ai engine to get me started.
(In fact, the other thread ultimately went unanswered as to “does this code look correct”, perhaps because the subject line was read carelessly or not borne in mind.)
This criticism is unfounded, and I am more of a beginner than you… since you’re restricted to a 19 years old version of a language I assume you already work or code for some project. But your method is wrong.
You won’t be able to “pick it up” like you aim to, you must follow a course or decently sized tutorial from start to finish, withouts skipping, like someone who’s never heard about programming at all. Drop the AI, forget imported codes you don’t assimilate, forget the RM for the most part, and shelf the Barnes too… Barnes’ good to explain techincaly points but to learn programming as a whole from them is a bit like French from the dictionary and a book on compared linguistics.
The daunting complexity of Ada95 file i/o is nowhere shown on the polar scale of tutorials from lightweight Lovelace (Wheeler, a part time instructor) to welterwight Ada-tutr (Herro, a professional educator) to no-weight AdaCore (pieces connected by CFL (C first language) programmers) .
As far as middleweight textbooks to teach Ada95, Feldman et al 3rd don’t even teach file i/o as the index entries and text content show. It is taught in Cohen 2 ed. in about 66 pages of densely packed, variable, upper case fonts not to be read in moving vehicles. Barnes and SPARK are another story from a sniffy UK proff-type.
A source for Ada answers is claimed public experts (for example teaching Ada95 as Ada2021 was meant to be used relying on Ada95RM as a programming oracle).
AI can be helpful for simple questions if one does not mind references which do not exist.
Another source is this public forum.
Therefore, thank you for your opinion.
Try from this example from this site.
That particular class notes have a lot of examples also homeworks.
Good to know Ada is still taught at the 300 level at that university in VA.
Confusing is the itio./tio. stuff ala Feldman etc 3rd. I like just USE.
You missed Beginning Ada Programming_ From Novice to Professional by Andrew T.Shvets and the one I use, Ada 95 The Craft Of Object-Oriented Programming. Both long, thorough and full of easy to read exemples. With basic to advanced file manipulation too.