Solved

reading textfiles

Posted on 2003-11-06
3
217 Views
Last Modified: 2010-04-16
When I run the program it has to read from a file called INVENTOR, so when the program exexutes and comes to the part where it has to read from the file it  displays
Input file `Inventor':
when i put inventor then press enter i get this message
./program: cannot open file `inventor' for reading (No such file or directory) (error #442 at 11c33)

i want it so the program just reads the file and not prompts me this (Input file `Inventor':) line
how do i fix this?

thanks
0
Comment
Question by:vyhoang
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9698753
This seems to be related to this question
http://www.experts-exchange.com/Programming/Programming_Languages/Pascal/Q_20790139.html


This sounds a lot like homework. It is agains EE policy for members to do homework OR for members to request solutions to homework. Has something to do the "academic honesty".

That said, what do you know how to do inPascal?  Show us your code so far and we would be happy to answer your specific questions.

Post the code you have written that is giving the trouble and we can try to help.

mlmcc

0
 

Author Comment

by:vyhoang
ID: 9698778
Procedure LoadFile;
BEGIN
   reset(INVENTOR);
   Count := 0;
   Sum := 0;
   WHILE NOT eof (INVENTOR) DO
   BEGIN
      readln(INVENTOR, id, instock, min, price, name);
      Count := Count + 1;
      Sum := Sum + price;
   end;
   writeln('There are ', Count, 'items in stock');
   writeln('The total retail is ', Sum);
end; { LoadFile }

I'm sorry i didn't know we had to post the code
This is a section of the code where the file is being loaded, the same problem applies, could you possible help me fix it
0
 
LVL 48

Accepted Solution

by:
dbrunton earned 50 total points
ID: 9699681
Looks like you're missing the Assign procedure.  Probably something like this

var
 f: text;

Assign(f, 'INVENTOR');
Reset(f);

All references to the file should use f and not INVENTOR.  You may even need to specify the path to the file such as

Assign(f, 'A:\INVENTOR');

depending on your computer system.

As mlmcc says if you are having problems post code.  And we don't do homework but can help you solve your problems.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question