* Re: Text Files
2000-05-23 0:00 ` Cameron McShane
@ 2000-05-23 0:00 ` John English
2000-05-23 0:00 ` Ted Dennison
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: John English @ 2000-05-23 0:00 UTC (permalink / raw)
Cameron McShane wrote:
> I have the program writing to a file etc, however only when using a direct
> filename, ie
>
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => "c:\biff.txt");
>
> This works beautifully.
>
> When I try and get user input for the name of the string, ie
>
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
> it doesn't work
When you say "it doesn't work" what exactly do you mean? Your code
looks fine (in isolation); do you get an exception of some sort
when you run it? If so, which one?
In particular, is Filename declared to be big enough to hold the
name you type in? Have you tried displaying the values of Last
and Filename(1..Last) to make sure they're what you expect?
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-23 0:00 ` Cameron McShane
2000-05-23 0:00 ` John English
@ 2000-05-23 0:00 ` Ted Dennison
2000-05-23 0:00 ` tmoran
2000-05-23 0:00 ` Marin D. Condic
3 siblings, 0 replies; 14+ messages in thread
From: Ted Dennison @ 2000-05-23 0:00 UTC (permalink / raw)
In article <959088712.853876@hearts.q-net.net.au>,
"Cameron McShane" <cazza@aceonline.com.au> wrote:
> When I try and get user input for the name of the string, ie
>
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
> it doesn't work
>
> Any ideas what i am doing wrong?
Can you give more detail than "it doesn't work"? Are you getting an
exception? If so, which one? If not, why do you think its not working?
--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-23 0:00 ` Cameron McShane
2000-05-23 0:00 ` John English
2000-05-23 0:00 ` Ted Dennison
@ 2000-05-23 0:00 ` tmoran
2000-05-23 0:00 ` Marin D. Condic
3 siblings, 0 replies; 14+ messages in thread
From: tmoran @ 2000-05-23 0:00 UTC (permalink / raw)
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
>it doesn't work
What does "it doesn't work" mean? Your code looks good. In what
way does it fail?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-23 0:00 ` Cameron McShane
` (2 preceding siblings ...)
2000-05-23 0:00 ` tmoran
@ 2000-05-23 0:00 ` Marin D. Condic
2000-05-25 0:00 ` Cameron McShane
3 siblings, 1 reply; 14+ messages in thread
From: Marin D. Condic @ 2000-05-23 0:00 UTC (permalink / raw)
Cameron McShane wrote:
> When I try and get user input for the name of the string, ie
>
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
> it doesn't work
>
This looks like it ought to work presuming you have declared everything
properly. What compiler/version/OS are you using?
What you should try is echoing out the Filename string so you can see if
you are, in fact, reading everything you think you are reading. For
example, if the string variable is too short, you may not be getting the
full name. There is a chance that you may be getting extraneous
characters - perhaps left over from some previous input line that you
did not fully read. In any case, make sure that you are reading what you
*think* you are reading and that may help you solve the problem. If not,
strip down the program to *just* the declarations and code needed to
read the string & create the file. If this small sample doesn't work,
then post the code.
MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at: http://www.mcondic.com/
"I'd trade it all for just a little more"
-- Charles Montgomery Burns, [4F10]
======================================================================
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-23 0:00 ` Marin D. Condic
@ 2000-05-25 0:00 ` Cameron McShane
2000-05-25 0:00 ` Jean-Pierre Rosen
2000-05-26 0:00 ` Dale Stanbrough
0 siblings, 2 replies; 14+ messages in thread
From: Cameron McShane @ 2000-05-25 0:00 UTC (permalink / raw)
Hey all
Thanks everyone for your comments and help
It seems that I needed a skip_line before the get_line.
ie
Text_io.skip_line;
Text_io.get_line(Filename, Last);
Text_Io.Create(
File => In_Data,
Mode => Text_Io.Out_File,
Name => Filename(1..Last));
I was sure I had tried this already, but obviously I was mistaken.
Thanks again
Cameron
Marin D. Condic <mcondic-nospam@quadruscorp.com> wrote in message
news:392AF852.93E0EDBE@quadruscorp.com...
> Cameron McShane wrote:
> > When I try and get user input for the name of the string, ie
> >
> > Text_io.get_line(Filename, Last);
> > Text_Io.Create(
> > File => In_Data,
> > Mode => Text_Io.Out_File,
> > Name => Filename(1..Last));
> >
> > it doesn't work
> >
> This looks like it ought to work presuming you have declared everything
> properly. What compiler/version/OS are you using?
>
> What you should try is echoing out the Filename string so you can see if
> you are, in fact, reading everything you think you are reading. For
> example, if the string variable is too short, you may not be getting the
> full name. There is a chance that you may be getting extraneous
> characters - perhaps left over from some previous input line that you
> did not fully read. In any case, make sure that you are reading what you
> *think* you are reading and that may help you solve the problem. If not,
> strip down the program to *just* the declarations and code needed to
> read the string & create the file. If this small sample doesn't work,
> then post the code.
>
> MDC
> --
> ======================================================================
> Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
> Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
> Visit my web site at: http://www.mcondic.com/
>
> "I'd trade it all for just a little more"
> -- Charles Montgomery Burns, [4F10]
> ======================================================================
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-25 0:00 ` Cameron McShane
@ 2000-05-25 0:00 ` Jean-Pierre Rosen
2000-05-26 0:00 ` Dale Stanbrough
1 sibling, 0 replies; 14+ messages in thread
From: Jean-Pierre Rosen @ 2000-05-25 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]
Cameron McShane <cazza@aceonline.com.au> a �crit dans le message : 959260098.454638@hearts.q-net.net.au...
> Hey all
>
> Thanks everyone for your comments and help
>
> It seems that I needed a skip_line before the get_line.
>
> ie
> Text_io.skip_line;
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
> I was sure I had tried this already, but obviously I was mistaken.
>
Wouldn't you, by any chance, be reading an integer value before ? If you do:
-- assuming proper instantiation of Integer_IO
Get (I);
Get_Line (File_Name, Last);
the first Get will leave you in front of the End_Of_Line, and the Get_Line will read an empty string.
In this case, you don't really need a Skip_Line *before the Get_Line*. What you really need is a Skip_Line *after the Get*. Not
exactly the same thing...
--
---------------------------------------------------------
J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Text Files
2000-05-25 0:00 ` Cameron McShane
2000-05-25 0:00 ` Jean-Pierre Rosen
@ 2000-05-26 0:00 ` Dale Stanbrough
1 sibling, 0 replies; 14+ messages in thread
From: Dale Stanbrough @ 2000-05-26 0:00 UTC (permalink / raw)
Cameron McShane wrote:
> Hey all
>
> Thanks everyone for your comments and help
>
> It seems that I needed a skip_line before the get_line.
>
> ie
> Text_io.skip_line;
> Text_io.get_line(Filename, Last);
> Text_Io.Create(
> File => In_Data,
> Mode => Text_Io.Out_File,
> Name => Filename(1..Last));
>
> I was sure I had tried this already, but obviously I was mistaken.
I would suggest that you download my (actually the FSF's!) interactive
text_io simulator that lets you examine the effect of various input
routines.
It's at...
www.cs.rmit.edu.au/~dale/software/index.html
look for Io_View. I would certainly recommend that your lecturer installs
it on your computers for everyone to use.
Dale
^ permalink raw reply [flat|nested] 14+ messages in thread