comp.lang.ada
 help / color / mirror / Atom feed
* reading from a file
@ 2002-02-25 17:08 Deepie
  2002-02-25 17:23 ` John McCabe
  2002-02-27  2:45 ` Wannabe h4x0r
  0 siblings, 2 replies; 7+ messages in thread
From: Deepie @ 2002-02-25 17:08 UTC (permalink / raw)


Hi,

I am currently writing a program from which i need to read in from a file.

When trying to read from the file using a command such as Skip_Line(F), F
being the file handle, i generate an 'invalid parameter in use' error.

things like Get_Line(F, name, length) dont work either. am i missing
something here?

TIA

deepie





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

* Re: reading from a file
  2002-02-25 17:08 reading from a file Deepie
@ 2002-02-25 17:23 ` John McCabe
  2002-02-25 20:30   ` Deepie
  2002-02-27  2:45 ` Wannabe h4x0r
  1 sibling, 1 reply; 7+ messages in thread
From: John McCabe @ 2002-02-25 17:23 UTC (permalink / raw)


On Mon, 25 Feb 2002 17:08:01 -0000, "Deepie"
<deepie@no-spam.ntlworld.com> wrote:

>Hi,
>
>I am currently writing a program from which i need to read in from a file.
>
>When trying to read from the file using a command such as Skip_Line(F), F
>being the file handle, i generate an 'invalid parameter in use' error.
>
>things like Get_Line(F, name, length) dont work either. am i missing
>something here?

This sounds like something very obvious is wrong - give us an example
and (if you're not trying to get us to do your homework), you'll
probably get a reasonable answer. A few questions:

1) What is 'F' defined as?
2) What type of file-io are you using?
3) Have you opened the file for reading?

etc.




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

* Re: reading from a file
  2002-02-25 17:23 ` John McCabe
@ 2002-02-25 20:30   ` Deepie
  2002-02-25 20:46     ` sk
  0 siblings, 1 reply; 7+ messages in thread
From: Deepie @ 2002-02-25 20:30 UTC (permalink / raw)


F is defined as 'text_io.file_type'

i am using Sequentional_io

and the file is open

regards,
deepie


"John McCabe" <john.mccabe@emrad.ns.com> wrote in message
news:3c7a72b1.30319166@news.demon.co.uk...
> On Mon, 25 Feb 2002 17:08:01 -0000, "Deepie"
> <deepie@no-spam.ntlworld.com> wrote:
>
> >Hi,
> >
> >I am currently writing a program from which i need to read in from a
file.
> >
> >When trying to read from the file using a command such as Skip_Line(F), F
> >being the file handle, i generate an 'invalid parameter in use' error.
> >
> >things like Get_Line(F, name, length) dont work either. am i missing
> >something here?
>
> This sounds like something very obvious is wrong - give us an example
> and (if you're not trying to get us to do your homework), you'll
> probably get a reasonable answer. A few questions:
>
> 1) What is 'F' defined as?
> 2) What type of file-io are you using?
> 3) Have you opened the file for reading?
>
> etc.
>





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

* Re: reading from a file
  2002-02-25 20:30   ` Deepie
@ 2002-02-25 20:46     ` sk
  2002-02-26  9:20       ` John McCabe
  0 siblings, 1 reply; 7+ messages in thread
From: sk @ 2002-02-25 20:46 UTC (permalink / raw)


Hi,

>F is defined as 'text_io.file_type'
>
>i am using Sequentional_io
>
>and the file is open
>
>regards,
>deepie

Use Text_Io functions (Get_Line, Skip_Line etc) on 
"Text_Io.File_Type"

Use Sequential_Io functions on "Sequential_Io.File_Type"

If you really (**REALLY**) need to access text files
sequentially and access sequential files as text, you 
will probably need to use the various Stream abilities.

Ada.Streams;
Ada.Streams.Stream_Io;
Ada.Text_Io.Text_Streams (??? - check actual package name).
...

You also need to watch out for the mode you use to "Open"
a file. Reading from an output file, writing to an input
file, for examples, will bite you.

-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
------------------------------------



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

* Re: reading from a file
  2002-02-25 20:46     ` sk
@ 2002-02-26  9:20       ` John McCabe
  0 siblings, 0 replies; 7+ messages in thread
From: John McCabe @ 2002-02-26  9:20 UTC (permalink / raw)


On Mon, 25 Feb 2002 14:46:51 -0600, sk <noname@myob.com> wrote:

>Use Text_Io functions (Get_Line, Skip_Line etc) on 
>"Text_Io.File_Type"
>
>Use Sequential_Io functions on "Sequential_Io.File_Type"

What sk is saying here is that Get_Line, Skip_Line etc are not defined
for the generic package Ada.Sequential_IO. Sequential_IO is not a
'subclass' of Text_IO.





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

* Re: reading from a file
  2002-02-25 17:08 reading from a file Deepie
  2002-02-25 17:23 ` John McCabe
@ 2002-02-27  2:45 ` Wannabe h4x0r
  2002-02-28 17:25   ` Deepie
  1 sibling, 1 reply; 7+ messages in thread
From: Wannabe h4x0r @ 2002-02-27  2:45 UTC (permalink / raw)


On Mon, 25 Feb 2002 12:08:01 -0500, Deepie wrote:

> Hi,
> 
> I am currently writing a program from which i need to read in from a
> file.
> 
> When trying to read from the file using a command such as Skip_Line(F),
> F being the file handle, i generate an 'invalid parameter in use' error.
> 
> things like Get_Line(F, name, length) dont work either. am i missing
> something here?
> 
> TIA
> 
> deepie

You know there are simpler ways to do it. Heres how I do it...

with Ada.Text_IO; use Ada.Text_IO;

 TEXT : string(1..N);
 Length : Natural;
 File : File_type;

Open(File, IN_FILE, TEXT(1..Length));

MAIN: <some code in here>
	get_line(FILE, TEXT, LENGTH);
	put_line(TEXT(1..LENGTH)); -- You can split up and rearrange this stuff
							in any number of ways. --
	blah blah blah....

You get the picture. Sequential IO, when not necessary, is just a hassle.


Chris



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

* Re: reading from a file
  2002-02-27  2:45 ` Wannabe h4x0r
@ 2002-02-28 17:25   ` Deepie
  0 siblings, 0 replies; 7+ messages in thread
From: Deepie @ 2002-02-28 17:25 UTC (permalink / raw)


ok, cheers guys

:P

Deepie

"Wannabe h4x0r" <chris@dont.spam.me> wrote in message
news:ELXe8.11783$bs1.241207@sccrnsc01...
> On Mon, 25 Feb 2002 12:08:01 -0500, Deepie wrote:
>
> > Hi,
> >
> > I am currently writing a program from which i need to read in from a
> > file.
> >
> > When trying to read from the file using a command such as Skip_Line(F),
> > F being the file handle, i generate an 'invalid parameter in use' error.
> >
> > things like Get_Line(F, name, length) dont work either. am i missing
> > something here?
> >
> > TIA
> >
> > deepie
>
> You know there are simpler ways to do it. Heres how I do it...
>
> with Ada.Text_IO; use Ada.Text_IO;
>
>  TEXT : string(1..N);
>  Length : Natural;
>  File : File_type;
>
> Open(File, IN_FILE, TEXT(1..Length));
>
> MAIN: <some code in here>
> get_line(FILE, TEXT, LENGTH);
> put_line(TEXT(1..LENGTH)); -- You can split up and rearrange this stuff
> in any number of ways. --
> blah blah blah....
>
> You get the picture. Sequential IO, when not necessary, is just a hassle.
>
>
> Chris





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

end of thread, other threads:[~2002-02-28 17:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-25 17:08 reading from a file Deepie
2002-02-25 17:23 ` John McCabe
2002-02-25 20:30   ` Deepie
2002-02-25 20:46     ` sk
2002-02-26  9:20       ` John McCabe
2002-02-27  2:45 ` Wannabe h4x0r
2002-02-28 17:25   ` Deepie

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