* Re: Command Line Parameters
[not found] <m-bartz-1701950936420001@macgalois.ee.memst.edu>
@ 1995-01-17 17:10 ` fewellsj
1995-01-24 2:42 ` David Weller
[not found] ` <3fgsin$kc6@info4.rus.uni-stuttgart.de>
1 sibling, 1 reply; 14+ messages in thread
From: fewellsj @ 1995-01-17 17:10 UTC (permalink / raw)
In article <m-bartz-1701950936420001@macgalois.ee.memst.edu>, m-bartz@memphis.edu (Michael Bartz) writes:
> A very newbie question from a long-time C programmer:
>
> Can you pass command line arguments to an Ada program?
>
> How do you do it?
>
Yes you can pass command line arguments.
How you do it, depends on what system you're using,
but on the vax you can use the pragma command to import a procedure
from the system called LIB$GET_FORRIGN, this allows you to access any
command line parameters passed.
Steve.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command Line Parameters
1995-01-17 17:10 ` Command Line Parameters fewellsj
@ 1995-01-24 2:42 ` David Weller
1995-01-24 16:09 ` Tarjei Jensen
1995-01-26 12:54 ` Mats Weber
0 siblings, 2 replies; 14+ messages in thread
From: David Weller @ 1995-01-24 2:42 UTC (permalink / raw)
In article <1995Jan17.171040.8865@vax.sbu.ac.uk>,
<fewellsj@vax.sbu.ac.uk> wrote:
>In article <m-bartz-1701950936420001@macgalois.ee.memst.edu>, m-bartz@memphis.edu (Michael Bartz) writes:
>> Can you pass command line arguments to an Ada program?
>>
>Yes you can pass command line arguments.
>
>How you do it, depends on what system you're using,
>but on the vax you can use the pragma command to import a procedure
>from the system called LIB$GET_FORRIGN,
^^^^^^^^^^^^^^^
I've never seen a better Rationale as to why
Ada 95 has Ada.Command_Line :-)
--
Frustrated with C/C++, Pascal, Fortran? Ada95 _might_ be for you!
For all sorts of interesting Ada95 tidbits, run the command:
"finger dweller@starbase.neosoft.com | more" (or e-mail with "finger" as subj.)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command Line Parameters
1995-01-24 2:42 ` David Weller
@ 1995-01-24 16:09 ` Tarjei Jensen
1995-01-26 12:54 ` Mats Weber
1 sibling, 0 replies; 14+ messages in thread
From: Tarjei Jensen @ 1995-01-24 16:09 UTC (permalink / raw)
In article <3g1pf5$s3q@Starbase.NeoSoft.COM> dweller@Starbase.NeoSoft.COM (David Weller) writes:
> I've never seen a better Rationale as to why
> Ada 95 has Ada.Command_Line :-)
You should check out the new getopt package that Perl5 comes with. That shows
how a good command line package could have been done. Of course the age old VMS
command line stuff is more advanced (and informal standards are adhered to:
it is very rare to have to worry about how to get out of a VMS program).
The command_line package is better than nothing, but the times are changing.
Greetings,
--
// Tarjei T. Jensen
// tarjeij@ulrik.uio.no || +47 51 563411
// Support you local rescue centre: GET LOST!
// Working, but not speaking for the Norwegian Hydrographic Service.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command Line Parameters
1995-01-24 2:42 ` David Weller
1995-01-24 16:09 ` Tarjei Jensen
@ 1995-01-26 12:54 ` Mats Weber
1 sibling, 0 replies; 14+ messages in thread
From: Mats Weber @ 1995-01-26 12:54 UTC (permalink / raw)
> >How you do it, depends on what system you're using,
> >but on the vax you can use the pragma command to import a procedure
> >from the system called LIB$GET_FORRIGN,
the correct name is LIB$Get_Foreign
and you don't need to import the procedure if you use VAX Ada version >=
2.0: it is in the VAX-Ada supplied package Lib and it's full Ada name
Lib.Get_Foreign.
Mats
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <3fgsin$kc6@info4.rus.uni-stuttgart.de>]
[parent not found: <3fhub3$4gv@Starbase.NeoSoft.COM>]
* Re: C programmer with Newbie question
[not found] ` <3fhub3$4gv@Starbase.NeoSoft.COM>
@ 1995-01-18 13:50 ` David O'Brien
[not found] ` <D2MB10.33w@world.std.com>
1995-01-25 23:45 ` Tucker Taft
0 siblings, 2 replies; 14+ messages in thread
From: David O'Brien @ 1995-01-18 13:50 UTC (permalink / raw)
David Weller (dweller@Starbase.NeoSoft.COM) wrote:
: In article <3fgsin$kc6@info4.rus.uni-stuttgart.de>,
: Peter Hermann <ucaa2385@iris1.csv.ica.uni-stuttgart.de> wrote:
: >Michael Bartz (m-bartz@memphis.edu) wrote:
: >: Can you pass command line arguments to an Ada program?
: >
: >A.15 The Package Command_Line
: >
: > function Argument_Count return Natural;
: equiv to argc
: > function Argument (Number : in Positive) return String;
: equiv to argv[1]..argv[argc]
: > function Command_Name return String;
:
: equiv to argv[0]
Correct me if I am wrong, but passing command line parameters is *VERY*
implementation specific (I am assuming Ada83). I assumed "A.15" is a
reference to appendix A in the ARM. But, that was not what I found
there. Could someone please point me to the language (Ada83 or Ada9x)
this applies to and where in the ARM it it.
-- David O'Brien (dobrien@seas.gwu.edu)
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <D2MB10.33w@world.std.com>]
* Re: C programmer with Newbie question
[not found] ` <D2MB10.33w@world.std.com>
@ 1995-01-19 9:32 ` Peter Hermann
1995-01-20 16:55 ` Robert Dewar
0 siblings, 1 reply; 14+ messages in thread
From: Peter Hermann @ 1995-01-19 9:32 UTC (permalink / raw)
Robert A Duff (bobduff@world.std.com) wrote:
: The reference was to Ada 95, not Ada 83. The correct reference is
Unfortunately, the Ada95-team decided to change the letters of the
appendices/annexes. I ate it but unhappily.
In Ada83 the letters were easy to remember
A for Attributes, B for (Bragmas :-) Pragmas, etc.
In Ada95 you could have R for real-time, D for distributed,
F kept for implementation-dependent (chap13) and so on.
They have preferred other criteria.
--
Peter Hermann Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: C programmer with Newbie question
1995-01-18 13:50 ` C programmer with Newbie question David O'Brien
[not found] ` <D2MB10.33w@world.std.com>
@ 1995-01-25 23:45 ` Tucker Taft
1 sibling, 0 replies; 14+ messages in thread
From: Tucker Taft @ 1995-01-25 23:45 UTC (permalink / raw)
In article <3fj6bh$9a8@cronkite.seas.gwu.edu>,
David O'Brien <dobrien@seas.gwu.edu> wrote:
>David Weller (dweller@Starbase.NeoSoft.COM) wrote:
>: In article <3fgsin$kc6@info4.rus.uni-stuttgart.de>,
>: Peter Hermann <ucaa2385@iris1.csv.ica.uni-stuttgart.de> wrote:
>: >Michael Bartz (m-bartz@memphis.edu) wrote:
>: >: Can you pass command line arguments to an Ada program?
>: >
>: >A.15 The Package Command_Line
>: >
>: > function Argument_Count return Natural;
>
>: equiv to argc
Actually, Argument_Count is equivalent to argc-1. That is, it is
a count of "arguments" and does *not* include the command name itself.
>: > function Argument (Number : in Positive) return String;
>
>: equiv to argv[1]..argv[argc]
Actually, Argument(N) for N in 1..Argument_Count is
equivalent to argv[n] for (n = 1; n < argc; n++)
>: > function Command_Name return String;
>:
>: equiv to argv[0]
Right.
> ...
>-- David O'Brien (dobrien@seas.gwu.edu)
-Tucker Taft stt@inmet.com
Intermetrics, Inc.
Cambridge, MA 02138
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: C programmer with Newbie question
[not found] ` <3fgsin$kc6@info4.rus.uni-stuttgart.de>
[not found] ` <3fhub3$4gv@Starbase.NeoSoft.COM>
@ 1995-01-23 15:45 ` David Emery
1995-01-25 23:40 ` Tucker Taft
2 siblings, 0 replies; 14+ messages in thread
From: David Emery @ 1995-01-23 15:45 UTC (permalink / raw)
A similar package for Ada83 can be found in the ADAR 2.0 components.
dave
--
--The preceeding opinions do not necessarily reflect the opinions of
--The MITRE Corporation or its sponsors.
-- "A good plan violently executed -NOW- is better than a perfect plan
-- next week" George Patton
-- "Any damn fool can write a plan. It's the execution that gets you
-- all screwed up" James Hollingsworth
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: C programmer with Newbie question
[not found] ` <3fgsin$kc6@info4.rus.uni-stuttgart.de>
[not found] ` <3fhub3$4gv@Starbase.NeoSoft.COM>
1995-01-23 15:45 ` David Emery
@ 1995-01-25 23:40 ` Tucker Taft
2 siblings, 0 replies; 14+ messages in thread
From: Tucker Taft @ 1995-01-25 23:40 UTC (permalink / raw)
In article <3fgsin$kc6@info4.rus.uni-stuttgart.de>,
Peter Hermann <ucaa2385@iris1.csv.ica.uni-stuttgart.de> wrote:
>Michael Bartz (m-bartz@memphis.edu) wrote:
>: Can you pass command line arguments to an Ada program?
>
>Excerpt from LRM(version5.95) for Ada95 (not Ada83!):
Actually, the excerpt below seems to be from a slightly
older version. In version 5.95, the type is called
"Exit_Status" and the routine to set it is called
"Set_Exit_Status".
So "Exit_" should be inserted as indicated below.
>A.15 The Package Command_Line
>
> package Ada.Command_Line is
> pragma Preelaborate(Command_Line);
> function Argument_Count return Natural;
> function Argument (Number : in Positive) return String;
> function Command_Name return String;
> type Status is range implementation-defined;
^ Exit_
> Success : constant Status;
^ Exit_
> Failure : constant Status;
^ Exit_
> procedure Set_Status (Code : in Status);
^ Exit_ ^ Exit_
> private
> ... -- not specified by the language
> end Ada.Command_Line;
>
>--
>Peter Hermann Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
>Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
>Team Ada: "C'mon people let the world begin" (Paul McCartney)
-Tucker Taft stt@inmet.com
Intermetrics, Inc.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Command line parameters
@ 1999-01-17 0:00 Igor Izvarin
1999-01-17 0:00 ` Craig Garrett
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Igor Izvarin @ 1999-01-17 0:00 UTC (permalink / raw)
Hi,
Could anybody explain me how I can obtain filename parameter from command
line:
programe.exe -a -b -c120 -d240 filename.ext
because
FILENAME: STRING(1..80);
FILENAME := ARGUMENT(I);
doesnot work weel and I do not know exact length of filename.ext parameter.
I am using ObectAda compiler.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
@ 1999-01-17 0:00 ` Craig Garrett
1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 14+ messages in thread
From: Craig Garrett @ 1999-01-17 0:00 UTC (permalink / raw)
Here is some code that does exactly what you want: ( I apologize about the
indentation, cut and paste dont work that well)
- Craig
-- CreateOTP.ADA
-- Author: Craig Garrett
-- Ver 1.2
-- 28 MAY 1998
--
****************************************************************************
**
-- Creates a OneTimePad to encrypt ANY file.
-- CREATEOTP [filename] [size]
-- [filename] Specifies the name of the OneTimePad to be created.
-- [size] Specifies the size of the OneTimePad in bytes.
-- NOTE: The OneTimePad MUST be as large or larger than the file to be
encrypted.
-- After this OneTimePad has been used once, delete it. Do not use it
twice.
-- Also see ENCRYPT and DECRYPT for related commands.
--
****************************************************************************
**
with Ada.Command_Line;
with TEXT_IO;
use TEXT_IO;
with RANDOM;
with Interfaces;
with SEQUENTIAL_IO;
procedure CreateOTP is
package INT_IO is new TEXT_IO.INTEGER_IO (INTEGER);
use INT_IO;
package BYTE_FILE_IO is new SEQUENTIAL_IO(Interfaces.UNSIGNED_8);
use BYTE_FILE_IO;
procedure PRINT_HELP_INSTRUCTIONS is
begin
PUT("Creates a OneTimePad to encrypt ANY file."); NEW_LINE(2);
PUT("CREATEOTP [filename] [size]");NEW_LINE(2);
PUT(" [filename] Specifies the name of the OneTimePad to be
created.");NEW_LINE;
PUT(" [size] Specifies the size of the OneTimePad in
bytes."); NEW_LINE(2);
PUT("NOTE: The OneTimePad MUST be as large or larger than the file
to be encrypted.");NEW_LINE;
PUT("After this OneTimePad has been used once, delete it. Do not
use it twice.");NEW_LINE(2);
PUT("Also see ENCRYPT and DECRYPT for related
commands.");NEW_LINE(2);
end PRINT_HELP_INSTRUCTIONS;
Command_Length : NATURAL := 0; -- Used to specify a max length in the
GET call
I : INTEGER := 0; -- Index for the for loop when writing
the OneTimePad
OTPLength : INTEGER := 0;-- Length in bytes of the OneTimePad to
be created
OTP_FILE : BYTE_FILE_IO.FILE_TYPE; -- File Pointer to the
OneTimePad
OTP_NAME : STRING(1..50) := "
";
-- OneTimePad filename, 50 chars long just in case.
OTP_BYTE : Interfaces.UNSIGNED_8 := 0; -- Unsigned 8-bit Integer,
the byte written
-- to the OneTimePad.
begin
if Ada.Command_Line.Argument_Count = 2 then
OTP_NAME(1..Ada.Command_Line.Argument(1)'Last) :=
Ada.Command_Line.Argument(1);
Command_Length := Ada.Command_Line.Argument(2)'Last;
GET(Ada.Command_Line.Argument(2), OTPLength, Command_Length);
CREATE(OTP_FILE, OUT_FILE, OTP_NAME);
PUT("CREATING ONE-TIME-PAD: "); PUT(OTP_NAME);
RANDOM.GET_TIME_SEED;--Generates a new seed based on the system clock
for better randomness
for I in 1..OTPLength loop
--Generate a random unsigned, 8-bit integer, and write it to
the file
OTP_BYTE := Interfaces.Unsigned_8(RANDOM.NUMBER * 255.0);
WRITE(OTP_FILE, OTP_BYTE);
end loop;
CLOSE(OTP_FILE);
else
-- Classic command line behavior, if no or incorrect command line
parameters...
PRINT_HELP_INSTRUCTIONS;
end if;
exception -- This is in case the given command line parameters are
incorrect.
when OTHERS =>
PRINT_HELP_INSTRUCTIONS;
end CreateOTP;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` Craig Garrett
@ 1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 14+ messages in thread
From: David C. Hoos, Sr. @ 1999-01-17 0:00 UTC (permalink / raw)
Igor Izvarin wrote in message <77tm5p$kls$1@scelto.ts.kiev.ua>...
>Hi,
>
>Could anybody explain me how I can obtain filename parameter from command
>line:
>
>programe.exe -a -b -c120 -d240 filename.ext
>
>because
>
>FILENAME: STRING(1..80);
>
>FILENAME := ARGUMENT(I);
>
There is no need to declare a string for the filename, as the
command name is available as Ada.Command_Line.Command_Name;
If you must assign it to your own string, you can do so without
knowing its length as follows:
Filename : constant String := Ada.Command_Line.Command_Name;
Which Ada95 compiler is used makes no difference.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` Craig Garrett
1999-01-17 0:00 ` David C. Hoos, Sr.
@ 1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 14+ messages in thread
From: Jerry van Dijk @ 1999-01-18 0:00 UTC (permalink / raw)
Igor Izvarin (izvarin@microsoft.ru.kiev.ua) wrote:
: Could anybody explain me how I can obtain filename parameter from command
: line:
There are lots of ways. From the question, I guess you are looking for
something like:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Display is
Data : array (1 .. Argument_Count) of Unbounded_String;
begin
for I in Data'Range loop
Data (I) := To_Unbounded_String (Argument (I));
end loop;
for I in Data'Range loop
Put_Line (To_String (Data (I)));
end loop;
end Display;
--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~1999-01-18 0:00 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <m-bartz-1701950936420001@macgalois.ee.memst.edu>
1995-01-17 17:10 ` Command Line Parameters fewellsj
1995-01-24 2:42 ` David Weller
1995-01-24 16:09 ` Tarjei Jensen
1995-01-26 12:54 ` Mats Weber
[not found] ` <3fgsin$kc6@info4.rus.uni-stuttgart.de>
[not found] ` <3fhub3$4gv@Starbase.NeoSoft.COM>
1995-01-18 13:50 ` C programmer with Newbie question David O'Brien
[not found] ` <D2MB10.33w@world.std.com>
1995-01-19 9:32 ` Peter Hermann
1995-01-20 16:55 ` Robert Dewar
1995-01-25 23:45 ` Tucker Taft
1995-01-23 15:45 ` David Emery
1995-01-25 23:40 ` Tucker Taft
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` Craig Garrett
1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-18 0:00 ` Jerry van Dijk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox