From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,691bbbf0ab0cc67e X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: [Q] Returning Strings From A Function Date: 1997/04/05 Message-ID: #1/1 X-Deja-AN: 230959873 References: <33454165.1658515@news.demon.co.uk> <33468b81.762963@news.demon.co.uk> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-04-05T00:00:00+00:00 List-Id: In article <33468b81.762963@news.demon.co.uk>, John McCabe wrote: > File_Name : constant string := Text_IO.Name (File); I don't remember if you were specifically asking about Ada 83, but Ada 95 also allows: File_Name : String := Text_IO.Name (File); which allows you to change the characters of File_Name, but not its length. >type File_Name_Type is new String (1..12); > >then use:- > >procedure ... > > File_Name : File_Name_Type; > >begin > : > File_Name := Text_IO.Name (File); > : >end... > >or something similar. But unfortunately this is obviously not >possible. Did anyone suggest this: type String_Ptr is access String; procedure ... File_Name : String_Ptr; begin : File_Name := new String'(Text_IO.Name (File)); : end... ? Then you can change the length of the string by throwing away the old one, and creating a new one on the heap. In Ada 83, you have to worry about storage management. In Ada 95, you can encapsulate the storage management using a controlled type -- and that's essentially what the Strings.Unbounded package does. - Bob