JohnWFul Sat Jan 19 2008 at 2:23 am RE: keypress...
Hmm.. That does seem to be the best thing for this small job..
I suppose though I could make a menu exiting method on the bigger ones. I tried doing that on this program:
DECLARE SUB AddRecor (Student AS ANY)
DECLARE SUB DisplayRecord (Student AS ANY)
SCREEN 12: CLS
'*** Create Student File ***
'*** This program creates a random file of student ***
'*** records. Each record contains the following ***
'*** fields: ***
'*** Name ***
'*** Identification number ***
'*** Birth date ***
'*** Grade point average ***
'*** Number of credits student has earned ***
'*** The user can add a new record or display an ***
'*** existing record. ***
' File used: ***
' STUDENT.DAT ***
'*** Major variables: ***
'*** Student Student record ***
'*** RecNum Number of the current record ***
TYPE StudentRecord ' declare the record type
Nme AS STRING * 25
IDNumber AS STRING * 11
BirthDate AS STRING * 8
GPA AS SINGLE
Credits AS INTEGER
END TYPE
DIM Student AS StudentRecord
OPEN "STUDENT.DAT" FOR RANDOM AS #3 LEN = LEN(Student)
DO UNTIL (Choice = 3)
CLS
PRINT
PRINT
PRINT
LOCATE 6, 1
PRINT TAB(25); " 1. Add a new record"
PRINT TAB(25); " 2. Display an existing record"
PRINT TAB(25); " 3. Exit"
PRINT
PRINT
PRINT
PRINT
INPUT "Enter number of operation you wish to perform: ", Choice
SELECT CASE Choice
CASE 1
CALL AddRecor(Student)
CASE 2
CALL DisplayRecord(Student)
CASE 3
PRINT
PRINT "Record Saved. Goodbye."
CASE ELSE
PRINT "Invalid choice."
END SELECT
LOOP
CLOSE #3
END
SUB AddRecor (Student AS StudentRecord)
'*** This SUB procedure prompts the user to enter the data ***
'*** to a student record and then writes the record to the ***
'*** specified record location. ***
CLS
'*** Determine the record number to which data should be written. ***
INPUT "Enter student's record number: ", RecNum
'*** Get the needed record data. ***
INPUT "Enter student's name: ", Student.Nme
INPUT "Enter student's identification number: ", Student.IDNumber
INPUT "Enter student's birth date: ", Student.BirthDate
INPUT "Enter student's grade point average: ", Student.GPA
INPUT "Enter number of credits: ", Student.Credits
'*** Write the record. ***
PUT #3, RecNum, Student
END SUB
SUB DisplayRecord (Student AS StudentRecord)
'*** This procedure prompts the user to enter a record number ***
'*** and then displays this record's fields. ***
CLS
PRINT
PRINT
PRINT
PRINT
INPUT "Enter the student's number: ", RecNum
GET #3, RecNum, Student
'*** Display the fields. ***
PRINT
PRINT
PRINT "Name"; TAB(28); "ID Number"; TAB(41); "Birth Date"; TAB(53); "GPA"; TAB(59); "Number of Credits"
PRINT Student.Nme; TAB(27); Student.IDNumber; TAB(42); Student.BirthDate; TAB(52); Student.GPA; TAB(65); Student.Credits
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
INPUT "Press <Enter> to return to main menu.", Go$
END SUB
and it seems to be working well...
I have yet another small question though..
WHEN YOU COMPILE AN EXE with QuickBasic 4.5, Using the option:
"Stand-Alone EXE File"
How come I get 2 files out of the conversion process?
I get my EXE file and then I get an "OBJ" File?
What the heck is an OBJ file?? I deleted the OBJ file for this program when I converted it to an EXE and the program seems to work perfectly fine without the OBJ file.
DO I need the OBJ file at all? / What does an OBJ file do?
THANKS, :-)
ALSO: E-Mail: JohnWFul@Hotmail.com
|