comp.lang.ada
 help / color / mirror / Atom feed
From: pvanbell@cloud9.net (Paul Van Bellinghen)
Subject: Using Posix with Apex
Date: 1997/01/28
Date: 1997-01-28T00:00:00+00:00	[thread overview]
Message-ID: <32ee8e2c.1005715@NEWS.CLOUD9.NET> (raw)



 I don't know how many of you are using Rational Apex, but if you are
and want to write any code to extract arguments from a command line,
I had a devel of a time doing it. I recently modified a program that
counted lines of Ada code to take its two arguments (output file,
input file list) from the command line. I was compiling it with
Rational Apex and so I used the Posix
package provided. In order to get say, the first argument on the
command line, I wrote:

Output_File_Name.Name :=
	   Posix.To_String (Posix.Value
           (Posix_Process_Environment.Argument_List, 2));

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));

The problem was that Output_File_Name.Name and the argument to be
assigned to it had different lengths. This is not allowed by Ada's
rules for assigning to arrays - you must specify which elements of
the array are to be assigned values when the right-hand-side is
shorter than the left-hand-side.






             reply	other threads:[~1997-01-28  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-28  0:00 Paul Van Bellinghen [this message]
1997-01-29  0:00 ` Using Posix with Apex Matthew Heaney
1997-01-30  0:00   ` Dr. Peter E. Obermayer
1997-02-10  0:00     ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox