Department of Energy Argonne National Laboratory Office of Science NEWTON's Homepage NEWTON's Homepage
NEWTON, Ask A Scientist!
NEWTON Home Page NEWTON Teachers Visit Our Archives Ask A Question How To Ask A Question Question of the Week Our Expert Scientists Volunteer at NEWTON! Frequently Asked Questions Referencing NEWTON About NEWTON About Ask A Scientist Education At Argonne Sequencial File Development
Name: Lisa
Status: Student
Age: 20s
Location: N/A
Country: N/A
Date: Around 1999


Question:
Im working on a QBasic assignment for class. And its killing me. Im supposed to be making a user menu for adding employee timecards and editing timecards. MY professor has insisted on making these sequential files. I cant figure out how to pull up these files to edit them. Ive read various pages on arrays but I cant seem to be able to implement it. Can you PLeeeease help?



Replies:
Since you said you were having problems with arrays, here is an example of how to use an array.

For your problem, you first have to declare an array for you your data, along with the information you are storing for each person. You will want to make the array large enough to hold all the employees you will ever need.

TYPE EmployeeInfo
   EmpName AS STRING * 40
   Address AS STRING * 40
   Phone AS STRING * 20
END TYPE

DIM a(1 TO 5) AS EmployeeInfo

Now that you have an array to store everything in, you have to get the data into the array. This section reads the data from the keyboard. You will want to read from your sequential file.
FOR x = 1 TO 5
    PRINT "Employee "; x; ":"
    PRINT "  Enter Name ";
    INPUT a(x).EmpName$
    PRINT "  Enter Address ";
    INPUT a(x).Address$
    PRINT "  Enter Phone ";
    INPUT a(x).Phone$
    PRINT
NEXT x

Then you get to do something with the data. This just prints it out. You will have to be able to edit, print, etc.
PRINT
PRINT "Employee List:"

FOR x = 1 TO 5
    PRINT "Employee "; x; ":"
    PRINT a(x).EmpName$
    PRINT a(x).Address$
    PRINT a(x).Phone$
    PRINT
NEXT x



Click here to return to the Computer Science Archives

NEWTON is an electronic community for Science, Math, and Computer Science K-12 Educators, sponsored and operated by Argonne National Laboratory's Educational Programs, Andrew Skipor, Ph.D., Head of Educational Programs.

For assistance with NEWTON contact a System Operator (help@newton.dep.anl.gov), or at Argonne's Educational Programs

NEWTON AND ASK A SCIENTIST
Educational Programs
Building 360
9700 S. Cass Ave.
Argonne, Illinois
60439-4845, USA
Update: June 2012
Weclome To Newton

Argonne National Laboratory