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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b46d62f4a7f83cd9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!bcklog2.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 10 Jan 2007 19:02:22 -0600 Date: Wed, 10 Jan 2007 19:51:10 -0500 From: Jeffrey Creem User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: problem with command line References: <45a58068$0$3828$5402220f@news.sunrise.ch> In-Reply-To: <45a58068$0$3828$5402220f@news.sunrise.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-1Iy/0KzA4O8a+/y6p64bdBgZnZ8+OG6wNfBgqonPWTcsYdH7lItOymzkbHyNaD1CLMD4SRHzByTD+8L!N9ANKRupCAO1Agi4qfQA1Ic9C0cVqxr2ZPebSP6CXvWQJ6jSnG8bWDc6zywUdRPEmjO/yCObqw7W!STw= X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:8106 Date: 2007-01-10T19:51:10-05:00 List-Id: [Taz] wrote: > hi, > I have a problem with the command line ... > I declare two variables like in the code below. > If the call to my file don't have parameter, I get a error ... > How can I solve this? > ... > > procedure Test is > > Nome1 : String := Argument (1); > > Nome2 : String := Argument (2); > > ... > > Check to Ada.Command_Line.Argument_Count first to be sure that you actually have parameters 1 and 2. This will of course require that you not declare strings and assign them during declaration but then this requires you to use access types for the strings or accessor functions or some other method. For example, you could create a function like function Get_Argument_And_Null_If_Not_Present(I : Positive) return String is begin if Ada.Command_Line.Argument_Count >= I then return Ada.Command_Line.Argument(I); else return ""; end if; end Get_Argument_And_Null_If_Not_Present; And use that to fill in your strings. It very much depends on what you are trying to accomplish.