Solved

can't find file?

Posted on 2000-03-22
2
219 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 48

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE, DataSnap, JSon and java 8 1,120
Error on close dbExpress with datasnap 5 581
Lazarus and Excel formulas via OLE 7 344
Activex loadlibrary and show parented form issue 6 343
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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