Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

can't find file?

Posted on 2000-03-22
2
Medium Priority
?
221 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 120 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What we learned in Webroot's webinar on multi-vector protection.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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