Solved

can't find file?

Posted on 2000-03-22
2
217 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
Server side business logic 5 357
Setting up Idhttp indy component to use a proxy server 2 1,655
Consuming Server Sent Event (DOM events) in Delphi 1 779
.dat problems 39 208
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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