Solved

can't find file?

Posted on 2000-03-22
2
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 49

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

With the rising number of cyber attacks in recent years, keeping your personal data safe has become more important than ever. The tips outlined in this article will help you keep your identitfy safe.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

624 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