Solved

can't find file?

Posted on 2000-03-22
2
212 Views
Last Modified: 2010-04-16
Ok, here's the deal. This program should  process a list of applicants: name number of cigarettes smoked each day, and weight. If they meet the criteria (numb > 10) and (wt > 180) then a message should be printed 'Accepted". If not, then a message should be printed 'Rejected' and also printed will be the reason why they're rejected. It should also print each applicant's name, number of cigarettes, and weight. (The 'Rejected'(+ reasons) or 'Accepted' should come after the name, cigarette# , and weight) For all 'Accepted' applicants, it should print the average number of cigarettes smoked daily and the average weight. Here's what I got sofar, but when I try to compile it, it gives me 'Cannot find file' on the reset(AppFile) line. I've created that file!

var name: string;
    numb: integer;
    wt: integer;
    AppFile: text;

procedure GETDATA (var AppFile: text;
                   var name: string;
                   var numb: integer;
                   var wt: integer);

  begin
    readln (AppFile, name);
    readln (AppFile, numb);
    readln (AppFile, wt);
  end; {GETDATA}

procedure POSITION (name: string;
                    numb: integer;
                    wt: integer);

    begin
      if (numb < 10) and (wt < 180) then
        writeln ('Accepted ');


      if not (numb < 10) and (wt < 180) then
           writeln ('Rejected ');
           writeln ('Your weight is more than the given weight ');
           writeln ('The number of cigarettes you smoke is over the limit ');
    end; {POSITION}

begin {main}
  assign (AppFile, 'AppFile2.dat');
  reset (AppFile);
  while not seekeof (AppFile) do
     begin
        GETDATA (AppFile, name, numb, wt);
        POSITION (name, numb, wt);
     end;
  close (Appfile)
end.

0
Comment
Question by:kazooie21
2 Comments
 
LVL 47

Accepted Solution

by:
dbrunton earned 30 total points
ID: 2648061
I don't know what compiler you are using because that error message seems strange.  

Here is the question.  Is the file in your compiler folder or directory?

You may have to specify folder that the file is in like the following line

assign(AppFile, 'c:\pascal\AppFile2.dat');


See if you can solve that problem first before considering the next section.

Comments on your coding:

In procedure GetData you don't need to use parameters.  You could use globals in this case unless you have been specifically told not to.  Similarly you don't need to use parameters in Postion as well.

If you do need to use parameters don't use the same names as the globals.  This can cause errors especially when debugging.  Use different names.  Here is Getdata with changes.

procedure GETDATA (var LocalAppFile: text;
                                      var Localname: string;
                                      var Localnumb: integer;
                                      var Localwt: integer);

begin
  readln(LocalAppFile, Localname);
  readln(LocalAppFile, Localnumb);
  readln(LocalAppFile, Localwt);
end;

I have used Local to indicate that these parameters are internal to this procedure only.  The syntax you use is up to you.
0
 
LVL 1

Expert Comment

by:nrico
ID: 2649179
Waitasec, you're ACCEPTING people on the basis of smoking regularly and being fat!!??
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

Suggested Solutions

Title # Comments Views Activity
send click   without cursor 6 371
Delphi need modify hand cursor windows 4 556
Inno Setup -> Add App Pin to Task Bar 1 536
code issue 8 85
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

18 Experts available now in Live!

Get 1:1 Help Now