Solved

reading textfiles

Posted on 2003-11-06
3
212 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 47

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now