comp.lang.ada
 help / color / mirror / Atom feed
* Command line
@ 2004-04-20 23:39 Andreas
  2004-04-21  0:32 ` Stephen Leake
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Andreas @ 2004-04-20 23:39 UTC (permalink / raw)


Hello

In a part of a program i'm writing, i need to read each row in a file and
check if the format is what i want it to be. I use a procedure (that takes
no arguments) to check if the format is OK. This procedure shall raise an
error if the format is bad, but will not handle the error; the procedure
that calls this procedure is supposed to do that.
I need to write the file name in the command line when i start my program.

To clear up the difficulties:

First i start the program by typing

myprog < data.txt

Then the main procedure runs, and calls the format check procedure, once for
each row in the file. If the format check procedure raised an error; handle
it in the main function (once error check for each call to the format check
procedure).

I've got a 500+ pages ADA programming book, but it doesn't help. I really
can't find what i'm looking for there.

Thanks in advance,

/Andreas





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-20 23:39 Command line Andreas
@ 2004-04-21  0:32 ` Stephen Leake
  2004-04-21  8:53 ` Preben Randhol
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Stephen Leake @ 2004-04-21  0:32 UTC (permalink / raw)
  To: comp.lang.ada

"Andreas" <andreasv@telia.com> writes:

> <snip description of requirements>
> 
> I've got a 500+ pages ADA programming book, but it doesn't help. I really
> can't find what i'm looking for there.

You've said what your code is supposed to do, but not what your
problem is.

This sounds like homework; if it's not please say so.

We can't write code for you, but we can answer specific questions
about how to do certain things.

In your case, Ada.Text_IO should have all the functions you need.

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-20 23:39 Command line Andreas
  2004-04-21  0:32 ` Stephen Leake
@ 2004-04-21  8:53 ` Preben Randhol
  2004-04-21 11:19 ` Jeff C,
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Preben Randhol @ 2004-04-21  8:53 UTC (permalink / raw)
  To: comp.lang.ada

Andreas <andreasv@telia.com> wrote on 21/04/2004 (08:15) :
> I've got a 500+ pages ADA programming book, but it doesn't help. I really
> can't find what i'm looking for there.

Could you please specify what the problem is exactly? And it is Ada not
ADA.

-- 
Preben Randhol -------------- http://www.pvv.org/~randhol/Ada95 --
                 �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-20 23:39 Command line Andreas
  2004-04-21  0:32 ` Stephen Leake
  2004-04-21  8:53 ` Preben Randhol
@ 2004-04-21 11:19 ` Jeff C,
  2004-04-21 14:07   ` Preben Randhol
  2004-04-22  2:00 ` Frank Beard
  2004-04-29 13:40 ` Richard  Riehle
  4 siblings, 1 reply; 12+ messages in thread
From: Jeff C, @ 2004-04-21 11:19 UTC (permalink / raw)



"Andreas" <andreasv@telia.com> wrote in message
news:rwihc.56765$mU6.234010@newsb.telia.net...
> Hello
>> I've got a 500+ pages ADA programming book, but it doesn't help. I really
> can't find what i'm looking for there.
>


We can't find what you are looking for in your help request. Perhaps you are
looking for
Ada.Command_Line which would allow you to actually process command line
arguments (such as the filename). Right now, you are using the OS to
redirect input which may or may not be compliant with the
requirement to get the filename from the command line.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-21 11:19 ` Jeff C,
@ 2004-04-21 14:07   ` Preben Randhol
  0 siblings, 0 replies; 12+ messages in thread
From: Preben Randhol @ 2004-04-21 14:07 UTC (permalink / raw)
  To: comp.lang.ada

"Jeff C," <jcreem@yahoo.com> wrote on 21/04/2004 (13:33) :
> 
> We can't find what you are looking for in your help request. Perhaps you are
> looking for
> Ada.Command_Line which would allow you to actually process command line
> arguments (such as the filename). Right now, you are using the OS to
> redirect input which may or may not be compliant with the
> requirement to get the filename from the command line.

To do 

some_program < file

it should be enough to use Ada.Text_IO.Standard_Input


-- 
Preben Randhol -------------- http://www.pvv.org/~randhol/Ada95 --
                 �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-20 23:39 Command line Andreas
                   ` (2 preceding siblings ...)
  2004-04-21 11:19 ` Jeff C,
@ 2004-04-22  2:00 ` Frank Beard
  2004-04-26 16:08   ` Andreas
  2004-04-29 13:40 ` Richard  Riehle
  4 siblings, 1 reply; 12+ messages in thread
From: Frank Beard @ 2004-04-22  2:00 UTC (permalink / raw)
  To: Andreas, comp.lang.ada

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 724 bytes --]


--- Andreas <andreasv@telia.com> wrote:
> I need to write the file name in the command line
> when i start my program.
<snip>
> myprog < data.txt
<snip>

If you are using Ada.Command_Line to pick up the name
"data.txt", then you don't need the "<" to redirect it
as standard input, or you could just pick up argument
number 2.  But it's better to drop the redirect, in
that case.

Otherwise, leave it the way you have it and just use
Get, Get_Line, etc. (without the "file" argument) from
Ada.Text_Io and it will be working with "data.txt" as
standard input.

Frank



	
		
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25�
http://photos.yahoo.com/ph/print_splash



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-22  2:00 ` Frank Beard
@ 2004-04-26 16:08   ` Andreas
  2004-04-26 17:19     ` Marius Amado Alves
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas @ 2004-04-26 16:08 UTC (permalink / raw)


Thanks for your answer. But, it actually didn't help. That's my fault; i
didn't specfy what my actual problem was. I'm so sorry for that.
Here i've got some code;

 procedure MyGet is
  sDate : string(1..10);
  e : exception;
 begin

   ada.exceptions.raise_exception(e'identity,"Format_Error");

 end;

procedure Test is
begin
  loop
     MyGet;
           exception
      when event: others =>
        ada.text_io.put(ada.exceptions.exception_message(event));
   end loop;
end;

"Test" is the first procedure called when i start my program. I start it
with the command line "Myprog < somedata.txt", so the data in "somedata.txt"
will be read in MyGet.

The problem here is, that i get (Using ObjectAda 7.2 at a Windows XP
machine) a compiler error. "Parse error: expected END_LOOP, got EXCEPTION,
Inserting END_LOOP".

How do i solve this?

Thanks in advance,

/Andreas

> If you are using Ada.Command_Line to pick up the name
> "data.txt", then you don't need the "<" to redirect it
> as standard input, or you could just pick up argument
> number 2.  But it's better to drop the redirect, in
> that case.
>
> Otherwise, leave it the way you have it and just use
> Get, Get_Line, etc. (without the "file" argument) from
> Ada.Text_Io and it will be working with "data.txt" as
> standard input.
>
> Frank





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-26 17:19     ` Marius Amado Alves
@ 2004-04-26 17:05       ` Andreas
  2004-04-26 19:56         ` Marius Amado Alves
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas @ 2004-04-26 17:05 UTC (permalink / raw)


That's right, i use a simple call to Get, with sDate as argument.

Get(sDate);

Sorry


"Marius Amado Alves" <maa@liacc.up.pt> skrev i meddelandet
news:mailman.8.1082998712.313.comp.lang.ada@ada-france.org...
>  procedure MyGet is
>   sDate : string(1..10);
>   e : exception;
>  begin
     -- ACTUAL CODE TO READ STUFF MISSING HERE, RIGHT?
>    ada.exceptions.raise_exception(e'identity,"Format_Error");
>
>  end;
>
> procedure Test is
> begin
>   loop
      BEGIN
>      MyGet;
>            exception
>       when event: others =>
>         ada.text_io.put(ada.exceptions.exception_message(event));
      END
>    end loop;
> end;





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-26 16:08   ` Andreas
@ 2004-04-26 17:19     ` Marius Amado Alves
  2004-04-26 17:05       ` Andreas
  0 siblings, 1 reply; 12+ messages in thread
From: Marius Amado Alves @ 2004-04-26 17:19 UTC (permalink / raw)
  To: comp.lang.ada

>  procedure MyGet is
>   sDate : string(1..10);
>   e : exception;
>  begin
     -- ACTUAL CODE TO READ STUFF MISSING HERE, RIGHT?
>    ada.exceptions.raise_exception(e'identity,"Format_Error");
>
>  end;
>
> procedure Test is
> begin
>   loop
      BEGIN
>      MyGet;
>            exception
>       when event: others =>
>         ada.text_io.put(ada.exceptions.exception_message(event));
      END
>    end loop;
> end;




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-26 19:56         ` Marius Amado Alves
@ 2004-04-26 19:52           ` Andreas
  0 siblings, 0 replies; 12+ messages in thread
From: Andreas @ 2004-04-26 19:52 UTC (permalink / raw)


Thank you a lot!

"Marius Amado Alves" <maa@liacc.up.pt> skrev i meddelandet
news:mailman.9.1083008137.313.comp.lang.ada@ada-france.org...
On Monday 26 April 2004 18:05, Andreas wrote:
> That's right, i use a simple call to Get, with sDate as argument.
>
> Get(sDate);

Good. Now make sure you don't miss the rest of my reply.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-26 17:05       ` Andreas
@ 2004-04-26 19:56         ` Marius Amado Alves
  2004-04-26 19:52           ` Andreas
  0 siblings, 1 reply; 12+ messages in thread
From: Marius Amado Alves @ 2004-04-26 19:56 UTC (permalink / raw)
  To: comp.lang.ada

On Monday 26 April 2004 18:05, Andreas wrote:
> That's right, i use a simple call to Get, with sDate as argument.
>
> Get(sDate);

Good. Now make sure you don't miss the rest of my reply.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Command line
  2004-04-20 23:39 Command line Andreas
                   ` (3 preceding siblings ...)
  2004-04-22  2:00 ` Frank Beard
@ 2004-04-29 13:40 ` Richard  Riehle
  4 siblings, 0 replies; 12+ messages in thread
From: Richard  Riehle @ 2004-04-29 13:40 UTC (permalink / raw)



"Andreas" <andreasv@telia.com> wrote in message
news:rwihc.56765$mU6.234010@newsb.telia.net...
> Hello
>
> > I've got a 500+ pages ADA programming book, but it doesn't help. I
really
> can't find what i'm looking for there.

Thanks for the this information.   It sounds like something that
ought to be in this year's edition of Ada Distilled.  I'll try
to add an example in the next edition.

Hmmmmmmmmmmmm!  Any other examples that ought to be in
the next edition of Ada Distilled?

Richard Riehle






^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-04-29 13:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-20 23:39 Command line Andreas
2004-04-21  0:32 ` Stephen Leake
2004-04-21  8:53 ` Preben Randhol
2004-04-21 11:19 ` Jeff C,
2004-04-21 14:07   ` Preben Randhol
2004-04-22  2:00 ` Frank Beard
2004-04-26 16:08   ` Andreas
2004-04-26 17:19     ` Marius Amado Alves
2004-04-26 17:05       ` Andreas
2004-04-26 19:56         ` Marius Amado Alves
2004-04-26 19:52           ` Andreas
2004-04-29 13:40 ` Richard  Riehle

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