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=2.2 required=5.0 tests=BAYES_00,FROM_WORDY, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!bcklog2.nntp.dca.giganews.com!nntp.rcn.net!news.rcn.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 10 Jan 2007 18:47:59 -0600 Reply-To: "Frank J. Lhota" From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <45a58068$0$3828$5402220f@news.sunrise.ch> Subject: Re: problem with command line Date: Wed, 10 Jan 2007 19:47:56 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-RFC2646: Format=Flowed; Response Message-ID: NNTP-Posting-Host: 209.6.187.224 X-Trace: sv3-ZZxzmhoKAhUCjMyt02TY+XAeyn8bYDZCSnGbNiucpGKVG49zewyRXwg6MFBbyI5H9IQFBBQft1AMp19!pAHfuXdJW8ApDejzX48z7nIre+noftupdNbfc8JUsbAO6/O5BQ7ifQy/PGa58zeLpAlDCH8768Nr!Vg== X-Complaints-To: abuse@rcn.net X-DMCA-Complaints-To: abuse@rcn.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:8105 Date: 2007-01-10T19:47:56-05:00 List-Id: "[Taz]" wrote in message news:45a58068$0$3828$5402220f@news.sunrise.ch... > 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); > > ... The package Ada.Command_Line includes the function Argument_Count that returns the number of command line arguments. You can use it to make sure that there is an argument 2 before calling Argument(2). I would probably code your application something like this: with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Test is Nome1 : Unbounded_String; Nome2 : Unbounded_String; begin if Argument_Count >= 1 then Nome1 := To_Unbounded_String(Argument(1)); else Nome1 := To_Unbounded_String("Default_Nome1"); end if; if Argument_Count >= 2 then Nome2 := To_Unbounded_String(Argument(2)); else Nome2 := To_Unbounded_String("Default_Nome2"); end if; ... end Test; -- "All things extant in this world, Gods of Heaven, gods of Earth, Let everything be as it should be; Thus shall it be!" - Magical chant from "Magical Shopping Arcade Abenobashi" "Drizzle, Drazzle, Drozzle, Drome, Time for this one to come home!" - Mr. Wizard from "Tooter Turtle"