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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: need help learning Ada for a modula-2 programmer Date: Sat, 01 Feb 2014 23:09:16 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 2 Feb 2014 06:09:24 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6bab1dce10a849dba13303bd95a0f77d"; logging-data="30462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ppxx/kZbdMtIODzC9urC5lDNen7EgRuQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Cancel-Lock: sha1:jESXYuU75QttmErFvdWASn6dRak= Xref: news.eternal-september.org comp.lang.ada:18350 Date: 2014-02-01T23:09:16-07:00 List-Id: On 02/01/2014 07:47 PM, agent@drrob1.com wrote: > > PROCEDURE GetCommandLine(CommandLine : OUT String) is > BEGIN > n := argument_count; > k := 1; > > WHILE k <= n LOOP > move(argument(k),argstr); - tried this- > argstr := argument(k); -- and this. Neither works. Where is Argstr defined? > cmdlinefrag := cmdlinefrag & argstr; Same for Cmdlinefrag. > I don't understand how to get this working using standard strings. > This is easy for me using ARRAY OF CHARACTER types in M2 and > procedures from the Strings standard module. The actual length of Commandline is determined by the actual parameter. If you want to return a String of just the right length, you'll either need an out parameter of an (Un)Bounded_String type, or a function that returns String. For the latter approach, you could use recursion: function Command_Line return String is function Piece (Arg : in Positive) return String is -- Empty declarative part begin -- Piece if Arg > Ada.Command_Line.Argument_Count then return ""; elsif Arg = Ada.Command_Line.Argument_Count then return Ada.Command_Line.Argument (Arg); else return Ada.Command_Line.Argument (Arg) & ' ' & Piece (Arg + 1); end if; end Piece; begin -- Command_Line return Piece (1); end Command_Line; -- Jeff Carter "I'm particularly glad that these lovely children were here today to hear that speech. Not only was it authentic frontier gibberish, it expressed a courage little seen in this day and age." Blazing Saddles 88