* 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
0 siblings, 1 reply; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` David C. Hoos, Sr.
@ 1999-01-17 0:00 ` Craig Garrett
1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 8+ 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] 8+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
@ 1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-17 0:00 ` Craig Garrett
1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 8+ 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] 8+ messages in thread
* Command line parameters
@ 1999-01-17 0:00 Igor Izvarin
1999-01-17 0:00 ` David C. Hoos, Sr.
` (2 more replies)
0 siblings, 3 replies; 8+ 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] 8+ messages in thread
* Re: Command line parameters
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-17 0:00 ` Craig Garrett
@ 1999-01-18 0:00 ` Jerry van Dijk
2 siblings, 0 replies; 8+ 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] 8+ messages in thread
end of thread, other threads:[~1999-01-18 0:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-17 0:00 Command line parameters Igor Izvarin
1999-01-17 0:00 ` David C. Hoos, Sr.
1999-01-17 0:00 ` Craig Garrett
1999-01-18 0:00 ` Jerry van Dijk
[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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox