From: Jeffrey Creem <jeff@thecreems.com>
Subject: Re: problem with command line
Date: Wed, 10 Jan 2007 19:51:10 -0500
Date: 2007-01-10T19:51:10-05:00 [thread overview]
Message-ID: <h8eg74-agh.ln1@newserver.thecreems.com> (raw)
In-Reply-To: <45a58068$0$3828$5402220f@news.sunrise.ch>
[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.
prev parent reply other threads:[~2007-01-11 0:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-11 0:08 problem with command line [Taz]
2007-01-11 0:47 ` Frank J. Lhota
2007-01-11 9:02 ` Brian May
2007-01-11 10:39 ` Martin Krischik
2007-01-11 0:51 ` Jeffrey Creem [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox