Page 1 of 1

Help with EOF

Posted: Sat Dec 07, 2002 2:23 am
by Guest
:o Hi Everyone, I am writing a simple payroll program that calculates the pay rate by the hours worked etc. I am having a problem with the EOF, it shows up on the output screen, also I need to calculate the total employees weekly pay, everything else is OK, I have tried so many different variables but I can't seem to get it, Here is my short program, If you can help me I appreciate your expertise!!!! Thanks

QB40 Program

Code: Select all

'
'This program is designed to calculate a payroll report
'weekly pay is calculated by multiplying the hourly rate
'by hours worked. The wrap up module has the total number
'of employees and the total pay of the employees.
'
'Variables: Employee.name$= Name of Employee
' hours.worked=hours worked
' hourly.rate= hourly rate
' weekly.pay= weekly pay
' total.weekly.pay=weekly pay plus weekly pay
'
'
'
'
'
'
'**************************************************************************
'*************************Intialization**********************************
CLS 'Clear screen
LET Total.employees = 0
LET total.weekly.pay = 0
PRINT TAB(30); "Payroll Report"
PRINT
PRINT "Employee", "Hourly", "Hours", "Weekly"
PRINT "Name", "Rate", "Worked", "Pay"
PRINT
d1$ = "\            \##.##      ##,###       #,###.##"
t1$ = "Total employees=======>;  ###"
T2$ = "Total Weekly Pay=====>; $$##,###.##"
T4$ = "End of Report"

'************************************Process File***********************
READ employee.name$, hourly.rate, hours.worked
DO UNTIL employee.name$ = "EOF"
        LET total.employee = total.employee + 1
        LET weekly.pay = hourly.rate * hours.worked
        LET total.weekly.pay = weekly.pay + weekly.pay + weekly.pay + weekly.pay + weekly.pay
        PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
        READ employee.name$, hourly.rate, hours.worked
      
LOOP


'********************wrap up********************** *******************
PRINT
PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
PRINT USING t1$; total.employee
PRINT USING T2$; total.weekly.pay
PRINT
PRINT "End of Report"

'**********************Data Follows*****************************
DATA Joe Lomax, 7.70, 40
DATA Ed Mann, 6.05, 38.5
DATA Louis Orr, 8.10, 45
DATA Ted Simms, 9.5, 39.5
DATA Joan Zang, 12.0, 92
DATA EOF,0,0
end

Re: Help with EOF

Posted: Sat Dec 07, 2002 5:47 am
by Guest
what is happening is that the program doesn't detect that it the file line says eof until after it prints it. you can fix this by takeing eof outta your file and instead of just saying LOOP at the end of your prog say LOOP UNTIL(EOF(1))

Re: Help with EOF

Posted: Sat Dec 07, 2002 5:54 am
by Guest
;D Got it Thanks, That worked!!!!, now I have 1 little bug left in my program, adding the total of all employees and having it output to Total Weekly Pay, right now it just adds the last employee twice. I appreciate your help!!!!

Re: Help with EOF

Posted: Sat Dec 07, 2002 8:36 am
by crossroads
Try this (bold lines are changed):

CLS 'Clear screen
LET Total.employees = 0
LET total.weekly.pay = 0
PRINT TAB(30); "Payroll Report"
PRINT
PRINT "Employee", "Hourly", "Hours", "Weekly"
PRINT "Name", "Rate", "Worked", "Pay"
PRINT
d1$ = "\  \  ##.##  ##,###  #,###.##"
t1$ = "Total employees=======>  ###"
T2$ = "Total Weekly Pay=====> $$##,###.##"
T4$ = "End of Report"

'************************************Process File***********************
READ employee.name$, hourly.rate, hours.worked
DO UNTIL employee.name$ = "EOF"
  LET total.employee = total.employee + 1
  LET weekly.pay = hourly.rate * hours.worked
  LET total.weekly.pay = total.weekly.pay + weekly.pay
  PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
  READ employee.name$, hourly.rate, hours.worked
LOOP


'********************wrap up********************** *******************
PRINT
PRINT USING t1$; total.employee
PRINT USING T2$; total.weekly.pay
PRINT
PRINT "End of Report"

'**********************Data Follows*****************************
DATA Joe Lomax, 7.70, 40
DATA Ed Mann, 6.05, 38.5
DATA Louis Orr, 8.10, 45
DATA Ted Simms, 9.5, 39.5
DATA Joan Zang, 12.0, 92
DATA EOF,0,0
END