QBASIC PROJECT WORK [PLAYER]
Sunil Gavasker,the present president of BCCI is demanding for the computerized information of good cricket players. So, Prepare a Menu-Based Program Which should allow us to enter players code,name,DOB,role,Marital Status and so on and also should allow us to view, search, delete and edit records.
DECLARE SUB ADD ()
DECLARE SUB BOXX ()
DECLARE SUB DISPLAY1 ()
DECLARE SUB MENU ()
DECLARE SUB DISPLAY2 ()
DECLARE SUB DISPLAY3 ()
DECLARE SUB DISPLAY4 ()
DECLARE SUB DISPLAY5 ()
DECLARE SUB BOX1 ()
DECLARE SUB SEARCH ()
DECLARE SUB EDIT ()
DECLARE SUB DELETE ()
DECLARE SUB EXI ()
DECLARE SUB DAT ()
DECLARE SUB BOX ()
CLS
COLOR 14
LOCATE 6, 15: PRINT CHR$(218)
LOCATE 6, 16: PRINT STRING$(50, 242)
LOCATE 6, 66: PRINT CHR$(242)
FOR I = 7 TO 21
LOCATE I, 66: PRINT CHR$(242)
LOCATE I, 15: PRINT CHR$(242)
NEXT I
LOCATE 21, 66: PRINT CHR$(242)
LOCATE 21, 15: PRINT CHR$(242)
LOCATE 21, 16: PRINT STRING$(50, 242)
COLOR 10
LOCATE 15, 32: PRINT "Loading Your Main-Menu"
COLOR 10
LOCATE 23, 7: PRINT "Please Wait For Few Seconds. Your Main-Menu is getting prepared."
FOR I = 30 TO 50
COLOR 10
LOCATE 9, 1 + I: PRINT CHR$(219)
COLOR 10
LOCATE 10, 40: PRINT X * 5; "%"
X = X + 1
FOR J = 1 TO 50000: NEXT J
NEXT I
DO
CALL MENU
COLOR 14
INPUT "Enter your choice (1-10)"; CH
SELECT CASE CH
CASE 1
CALL ADD
CASE 2
CALL DISPLAY1
CASE 3
CALL DISPLAY2
CASE 4
CALL DISPLAY3
CASE 5
CALL DISPLAY4
CASE 6
CALL DISPLAY5
CASE 7
CALL SEARCH
CASE 8
CALL EDIT
CASE 9
CALL DELETE
CASE 10
CALL EXI
END SELECT
LOOP WHILE CH <> 10
END
SUB ADD
COLOR 4, 5
COLOR 15
OPEN "PLAYER.DAT" FOR APPEND AS #1
DIM N(100)
DO
OPEN "PLAYER.DAT" FOR INPUT AS #2
I = 1
WHILE NOT EOF(2)
INPUT #2, C, N$, D$, H$, R$
N(I) = C
I = I + 1
WEND
CLOSE #2
CLS
TOP:
CALL BOX1
LOCATE 2, 36: PRINT "Add data"
LOCATE 3, 33: PRINT STRING$(14, "*")
LOCATE 8, 4: INPUT "Enter Player's Code Number"; CN
FOR J = 1 TO 100
IF CN = N(J) THEN
CLS
LOCATE 6, 10: PRINT "Code Number Already Exist. Please Give new Code Number!!!"
GOTO TOP
END IF
NEXT J
LOCATE 9, 4: INPUT "Enter Player's Name"; N$
LOCATE 10, 4: INPUT "Enter Player's Date of Birth"; D$
LOCATE 11, 4: INPUT "Enter Player's Nationality"; H$
LOCATE 12, 4: INPUT "Enter Player's Role in Game"; R$
WRITE #1, CN, N$, D$, H$, R$
LOCATE 20, 15: INPUT "Do you want to add more data (Y/N)"; CH$
LOOP WHILE UCASE$(CH$) = "Y"
CLOSE #1
END SUB
SUB BOX
LOCATE 6, 15: PRINT CHR$(218)
LOCATE 6, 16: PRINT STRING$(50, 196)
LOCATE 6, 66: PRINT CHR$(191)
FOR I = 7 TO 21
LOCATE I, 66: PRINT CHR$(179)
LOCATE I, 15: PRINT CHR$(179)
NEXT I
LOCATE 21, 66: PRINT CHR$(217)
LOCATE 21, 15: PRINT CHR$(192)
LOCATE 21, 16: PRINT STRING$(50, 196)
END SUB
SUB BOX1
LOCATE 4, 1: PRINT CHR$(5)
LOCATE 4, 2: PRINT STRING$(77, 5)
LOCATE 4, 79: PRINT CHR$(5)
LOCATE 21, 79: PRINT CHR$(5)
LOCATE 21, 1: PRINT CHR$(5)
LOCATE 21, 2: PRINT STRING$(77, 5)
END SUB
SUB BOXX
CLS
LOCATE 4, 2: PRINT CHR$(218)
LOCATE 4, 3: PRINT STRING$(76, 196)
LOCATE 4, 79: PRINT CHR$(191)
FOR I = 5 TO 21
LOCATE I, 2: PRINT CHR$(179)
LOCATE I, 79: PRINT CHR$(179)
NEXT I
LOCATE 21, 79: PRINT CHR$(217)
LOCATE 21, 2: PRINT CHR$(192)
LOCATE 21, 3: PRINT STRING$(76, 196)
END SUB
SUB DAT
LOCATE 10, 30
PRINT STRING$(20, ">")
FOR I = 11 TO 15
LOCATE I, 30: PRINT CHR$(179)
LOCATE I, 49: PRINT CHR$(179)
NEXT I
LOCATE 15, 30
PRINT STRING$(20, "<")
END SUB
SUB DELETE
COLOR 4, 8
CLS
OPEN "PLAYER.DAT" FOR INPUT AS #1
OPEN "TEMP.DAT" FOR OUTPUT AS #2
COLOR 18
LOCATE 4, 2: PRINT CHR$(218)
LOCATE 4, 3: PRINT STRING$(76, 196)
LOCATE 4, 79: PRINT CHR$(191)
FOR I = 5 TO 21
LOCATE I, 2: PRINT CHR$(179)
LOCATE I, 79: PRINT CHR$(179)
NEXT I
LOCATE 21, 79: PRINT CHR$(217)
LOCATE 21, 2: PRINT CHR$(192)
LOCATE 21, 3: PRINT STRING$(76, 196)
COLOR 15
LOCATE 2, 36: PRINT "Delete data"
LOCATE 3, 33: PRINT STRING$(17, "*")
LOCATE 6, 4: INPUT "Enter Player's Code Delete Record"; PC
LOCATE 8, 4: PRINT "Deleted Data"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
IF PC <> CN THEN
WRITE #2, CN, N$, D$, H$, R$
ELSE
LOCATE 10, 4: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
LOCATE 12, 4: PRINT CN, N$, D$, H$, R$
END IF
WEND
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1, #2
KILL "PLAYER.DAT"
NAME "TEMP.DAT" AS "PLAYER.DAT"
END SUB
SUB DISPLAY1
COLOR 4, 6
COLOR 15
CLS
OPEN "PLAYER.DAT" FOR INPUT AS #1
CLS
CALL BOX1
LOCATE 2, 36: PRINT "Display all Data"
LOCATE 3, 33: PRINT STRING$(21, "*")
LOCATE 6, 2: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
PRINT TAB(3); CN, N$, D$, H$, R$
WEND
COLOR 0
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
SUB DISPLAY2
COLOR 4, 9
COLOR 7
OPEN "PLAYER.DAT" FOR INPUT AS #1
CLS
CALL BOX1
LOCATE 2, 33: PRINT "Display Data of Batsman"
LOCATE 3, 30: PRINT STRING$(28, "*")
LOCATE 6, 2: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
IF UCASE$(R$) = "BATSMAN" THEN PRINT CN, N$, D$, H$, R$
WEND
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
SUB DISPLAY3
COLOR 4, 0
COLOR 12
OPEN "PLAYER.DAT" FOR INPUT AS #1
CLS
CALL BOX1
LOCATE 2, 20: PRINT "Display Data of Players Having First Name S "
LOCATE 3, 18: PRINT STRING$(47, "*")
LOCATE 6, 2: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
L$ = LEFT$(N$, 1)
HH$ = UCASE$(L$)
IF HH$ = "S" THEN PRINT CN, N$, D$, H$, R$
WEND
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
SUB DISPLAY4
COLOR 4, 3
COLOR 14
OPEN "PLAYER.DAT" FOR INPUT AS #1
CLS
CALL BOX1
LOCATE 2, 28: PRINT "Display Data of Nepali Players"
LOCATE 3, 25: PRINT STRING$(35, "*")
LOCATE 6, 2: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
IF UCASE$(H$) = "NEPAL" THEN PRINT CN, N$, D$, H$, R$
WEND
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
SUB DISPLAY5
COLOR 4, 1
COLOR 15
OPEN "PLAYER.DAT" FOR INPUT AS #1
CLS
CALL BOX1
LOCATE 2, 28: PRINT "Display Data of All Rounder"
LOCATE 3, 25: PRINT STRING$(33, "*")
LOCATE 6, 2: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
IF UCASE$(R$) = "ALL ROUNDER" THEN PRINT CN, N$, D$, H$, R$
WEND
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
SUB EDIT
COLOR 4, 5
OPEN "PLAYER.DAT" FOR INPUT AS #1
OPEN "TEMP.DAT" FOR OUTPUT AS #2
CLS
COLOR 18
LOCATE 4, 2: PRINT CHR$(218)
LOCATE 4, 3: PRINT STRING$(76, 196)
LOCATE 4, 79: PRINT CHR$(191)
FOR I = 5 TO 21
LOCATE I, 2: PRINT CHR$(179)
LOCATE I, 79: PRINT CHR$(179)
NEXT I
LOCATE 21, 79: PRINT CHR$(217)
LOCATE 21, 2: PRINT CHR$(192)
LOCATE 21, 3: PRINT STRING$(76, 196)
COLOR 15
LOCATE 2, 36: PRINT "Edit Data"
LOCATE 3, 33: PRINT STRING$(15, "*")
LOCATE 6, 4: INPUT "Enter Player's Code to Edit Record"; PC
FLAG = 0
CLS
DO
CLS
CALL BOX1
INPUT #1, CN, N$, D$, H$, R$
IF CN <> PC THEN
WRITE #2, CN, N$, D$, H$, R$
ELSE
LOCATE 2, 36: PRINT "Edit Data"
LOCATE 3, 33: PRINT STRING$(15, "*")
PRINT : PRINT
LOCATE 6, 4: PRINT "Code No."
LOCATE 6, 18: PRINT "Name"
LOCATE 6, 32: PRINT "Date of Birth"
LOCATE 6, 47: PRINT "Nationality"
LOCATE 6, 63: PRINT "Player's Role"
LOCATE 8, 4: PRINT CN
LOCATE 8, 14: PRINT N$
LOCATE 8, 32: PRINT D$
LOCATE 8, 47: PRINT H$
LOCATE 8, 63: PRINT R$
LOCATE 10, 4
FLAG = 1
INPUT "Do you Want to Edit Data (Y/N)"; CH$
IF UCASE$(CH$) = "Y" THEN
LOCATE 12, 4: PRINT "Please Enter New Data"
LOCATE 13, 4: PRINT "Code No."
LOCATE 13, 18: PRINT "Name"
LOCATE 13, 32: PRINT "Date of Birth"
LOCATE 13, 47: PRINT "Nationality"
LOCATE 13, 63: PRINT "Player's Role"
LOCATE 14, 4: INPUT NNC
LOCATE 14, 14: INPUT NN$
LOCATE 14, 32: INPUT ND$
LOCATE 14, 47: INPUT NH$
LOCATE 14, 63: INPUT NR$
WRITE #2, NNC, NN$, ND$, NH$, NR$
CLS
CLS
CALL DAT
LOCATE 12, 34: PRINT "Data Edited!!!"
SLEEP 2
ELSE
WRITE #2, CN, N$, D$, H$, R$
END IF
END IF
LOOP WHILE NOT EOF(1)
LOCATE 11, 25
IF FLAG = 0 THEN
CALL DAT
LOCATE 12, 33: PRINT "DATA NOT FOUND"
LOCATE 14, 34: PRINT "Try Again!!!"
SLEEP 2
END IF
CLOSE #1, #2
KILL "PLAYER.DAT"
NAME "TEMP.DAT" AS "PLAYER.DAT"
END SUB
SUB EXI
COLOR 8, 10
CLS
COLOR 17
LOCATE 6, 15: PRINT STRING$(1, "*")
COLOR 15
LOCATE 12, 35: PRINT "Good Bye"
LOCATE 15, 33: PRINT "See You Again"
LOCATE 19, 24: PRINT "Program Designed By: Ashish Pokhrel"
COLOR 17
LOCATE 6, 16: PRINT STRING$(50, "*")
LOCATE 6, 66: PRINT STRING$(1, "*")
FOR I = 7 TO 21
LOCATE I, 66: PRINT STRING$(1, "*")
LOCATE I, 15: PRINT STRING$(1, "*")
NEXT I
LOCATE 21, 66: PRINT STRING$(1, "*")
LOCATE 21, 15: PRINT STRING$(1, "*")
LOCATE 21, 16: PRINT STRING$(50, "*")
END SUB
SUB MENU
COLOR 6, 3
CLS
COLOR 18
LOCATE 6, 15: PRINT CHR$(218)
COLOR 15
LOCATE 8, 36: PRINT "Main-Menu"
COLOR 10
LOCATE 10, 18: PRINT "1. Add Data"
LOCATE 11, 18: PRINT "2. Display all data"
LOCATE 12, 18: PRINT "3. Display data of only Batsman"
LOCATE 13, 18: PRINT "4. Display data whose name begins with S "
LOCATE 14, 18: PRINT "5. Display data of only Nepali People"
LOCATE 15, 18: PRINT "6. Display data of All Rounder"
LOCATE 16, 18: PRINT "7. Search Record by name"
LOCATE 17, 18: PRINT "8. Edit Record"
LOCATE 18, 18: PRINT "9. Delete Data"
LOCATE 19, 18: PRINT "10. Exit"
COLOR 18
LOCATE 6, 16: PRINT STRING$(50, 196)
LOCATE 6, 66: PRINT CHR$(191)
FOR I = 7 TO 21
LOCATE I, 66: PRINT CHR$(179)
LOCATE I, 15: PRINT CHR$(179)
NEXT I
LOCATE 21, 66: PRINT CHR$(217)
LOCATE 21, 15: PRINT CHR$(192)
LOCATE 21, 16: PRINT STRING$(50, 196)
END SUB
SUB SEARCH
COLOR 7, 4
CLS
OPEN "PLAYER.DAT" FOR INPUT AS #1
COLOR 18
LOCATE 4, 2: PRINT CHR$(218)
LOCATE 4, 3: PRINT STRING$(76, 196)
LOCATE 4, 79: PRINT CHR$(191)
FOR I = 5 TO 21
LOCATE I, 2: PRINT CHR$(179)
LOCATE I, 79: PRINT CHR$(179)
NEXT I
LOCATE 21, 79: PRINT CHR$(217)
LOCATE 21, 2: PRINT CHR$(192)
LOCATE 21, 3: PRINT STRING$(76, 196)
COLOR 15
FLAG = 0
LOCATE 2, 36: PRINT "Search data"
LOCATE 3, 33: PRINT STRING$(17, "*")
LOCATE 6, 4: INPUT "Enter Player's Code to Search Record"; PC
WHILE NOT EOF(1)
INPUT #1, CN, N$, D$, H$, R$
IF PC = CN THEN
LOCATE 8, 4: PRINT "Code No.", "Name", "Date of Birth", "Nationality", "Player's Role"
LOCATE 10, 4: PRINT CN, N$, D$, H$, R$
FLAG = 1
END IF
WEND
LOCATE 8, 4: IF FLAG = 0 THEN PRINT " Data Not Found."
LOCATE 23, 1: PRINT TAB(24); "Press Any Key to Goto Main-Menu"
X$ = INPUT$(1)
CLOSE #1
END SUB
Comments