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,50b41333767ba40f X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Using Posix with Apex Date: 1997/01/29 Message-ID: #1/1 X-Deja-AN: 212996370 references: <32ee8e2c.1005715@NEWS.CLOUD9.NET> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1997-01-29T00:00:00+00:00 List-Id: In article <32ee8e2c.1005715@NEWS.CLOUD9.NET>, pvanbell@cloud9.net (Paul Van Bellinghen) wrote: >Output_File_Name.Name := > Posix.To_String (Posix.Value > (Posix_Process_Environment.Argument_List, 2)); If you don't know the length of the string returned by a function, then in Ada 83 just declare the object as a constant in some dynamic scope: declare The_Name : constant POSIX_String := POSIX.Value (POSIX_Process_Environment.Argument_List, 2); begin Output_File_Name.Name (1 .. The_Name'Length) := POSIX.To_String (The_Name); end; >however, I kept getting an "invalid argument" exception when the code >was executed. I called the Rational support team and found out that >the line suld read > > Output_File_Name.Name > (1 .. Posix.To_String > (Posix.Value (Posix_Process_Environment.Argument_List, 2))' > Length) := > Posix.To_String (Posix.Value > (Posix_Process_Environment.Argument_List, 2)); Rational gave you some bad advice. Please don't write code like this: you're calling the function twice, and it's completely unreadable. This is not an Ada "problem." Use declare blocks to hold intermediate values, especially for the result of a function that returns an unconstrained array. (Just remember: in Ada 83 you have to declare the object as a constant; this rule went away in Ada 95.) -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271