Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!spool.mu.edu!caen!hearst.acc.Virginia.EDU!fennel.cs.hamptonu.edu!cezzar
From: cezzar@cs.hamptonu.edu (Dr. Ruknet Cezzar)
Subject: turbo prolog program
Message-ID: <1994Oct27.162904.23237@fennel.cs.hamptonu.edu>
Originator: cezzar@apple.cs.hamptonu.edu
Keywords: recursion
Sender: usenet@fennel.cs.hamptonu.edu (News Account)
Nntp-Posting-Host: apple.cs.hamptonu.edu
Organization: Hampton University - Dept. of Computer Science
Date: Thu, 27 Oct 1994 16:29:04 GMT
Lines: 123



Numerous attempts to get help with my problem with Borland's early Turbo
Prolog (Version 1.0) for MS-DOS systems encountered with "Turbo Prolog" 
being unlike others, etc.. Therefore, I thought you would be more familiar
with this Prolog dialect.

Meanwhile, I would not mind updating the above Turbo Prolog with something
better (have MS-DOS 5.0 386 Machine).   


See below INPUT - wepay.dat    
          PROLOG PROGRAM (MS-DOS Borlands Turbo 1.00) 
          OUTPU - wepay.prt

I am supposed to do change of variables like Salary1, Emp_id1, etc. and
then use recursion to read in and print all "four' records (not just the
one!).  Frustrated with various permutations of these variable name changes
for the correct bindings...

and need HELP....!.

please mail your suggestions to cezzar@cs.hamptonu.edu

Sincerely.Sincerely.Sincerely.

Ruknet Cezzar, Assoc. Professor 
Dept. of Computer Science, Hampton University
Hampton, Virginia 23668
email: cezzar@cs.hamptonu.edu
tel: 804-727-5558

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INPUT:

Frederickson 
162700
182.50
576.13
Butterfluko
888999
175.12
676.15
Erickson
123456
200.00
715.24)
Tweedledotweedy
222333
350.77
125.12

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 PROGRAM: 

/* P R O L O G   Program WEPAY  for weekly pay           */
/***** NOTE: this program require further modifications - rc 8/7/93 */
domains
  file  = out_file; in_file      /*  input output file type declaration  */
  Salary, Sales_amt, Gross_pay = real  /*  base pay, sales, gross pay  */
  Last_name, Emp_id  = symbol    /*  alphanumeric strings actually */
  field = string               /*  a direct string declaration    */
 
predicates
   write_report(Salary,Sales_amt,Gross_pay)
   get_input(Last_name, Emp_id, Salary, Sales_amt)
   write_header
   calculate_pay(Salary,Sales_amt,Gross_pay)  
   reptdate (field)
                 
goal
   openread(in_file,"wepay.dat"),
   openwrite(out_file,"wepay.prt"),
   write_header,
   write_report(_,_,_),
   closefile(out_file),
   closefile(in_file).

clauses
   write_report (Salary,Sales_amt,Gross_pay)
   :-  get_input(Last_name, Emp_id, Salary, Sales_amt),       
       calculate_pay (Salary, Sales_Amt, Gross_pay),
       write ("          ",Emp_id, "          ",Last_name, "        $ ", Gross_pay).
       
   get_input(Last_name, Emp_id, Salary, Sales_amt)     
   :- readdevice(in_file),
      not(eof(in_file)),
      readln(Last_name),
      readln(Emp_id),
      readreal(Salary),
      readreal(Sales_amt).   

   write_header
   :- writedevice(out_file),

      write ("          PAYROLL FOR THE WEEK ENDING         "),
      reptdate(Name), write(Name), nl,
      write ("          EMPLOYEE ID     LAST NAME           GROSS PAY\n"),
      write ("          -----------     ---------------     ---------\n").

    calculate_pay (Salary,Sales_amt,Gross_pay) 
    :- Sales_amt  > 100, 
       Gross_pay  = Salary + 0.04 * (Sales_amt - 100);
       Salary  <= 100, 
       Gross_pay = Salary.
                 
    reptdate ("01/03/93\n").

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


 OUTPUT:

          PAYROLL FOR THE WEEK ENDING         01/03/93

          EMPLOYEE ID     LAST NAME           GROSS PAY
          -----------     ---------------     ---------
          888999          Butterfluko        $ 198.166

           <<<< the other lines expected >>>>>>>>>>>>>>>>>
++++++++++++++++++++++++++ E O M +++++++++++++++++++++++++++++++++++++++++

