Guest_imported
New member
- Jan 1, 1970
- 0
Here's what I'm building:
A program to assist in running the Cub Scout Pinewood Derby. I'm writing this in QBasic because the people who may be maintaining this program in the future need a free, easy programming module that does not require compilation to run.
Basically what I've done so far is write sub procedures to enter data, view data, edit data, and delete data. What I need now is a way to update these when a race is complete and offer a ranking system... and I'm drawing a blank... The code is posted below. Thanks in advance to everyone who helps...
-William Kenny
Programmer for KennySoft Solutions
A program to assist in running the Cub Scout Pinewood Derby. I'm writing this in QBasic because the people who may be maintaining this program in the future need a free, easy programming module that does not require compilation to run.
Basically what I've done so far is write sub procedures to enter data, view data, edit data, and delete data. What I need now is a way to update these when a race is complete and offer a ranking system... and I'm drawing a blank... The code is posted below. Thanks in advance to everyone who helps...
-William Kenny
Programmer for KennySoft Solutions
Code:
DECLARE SUB DelData ()
DECLARE SUB AVG ()
DECLARE SUB RaceSetup ()
DECLARE SUB RaceStart ()
DECLARE SUB CheckNoRacers ()
DECLARE SUB EditDB ()
DECLARE SUB GetData ()
DECLARE SUB EnterData ()
ON ERROR GOTO ErrHndlr
SCREEN 11
TYPE TgrRecord
LstNme AS STRING * 10
FstNme AS STRING * 10
CarNo AS INTEGER
CarOz AS STRING * 3
Lane1 AS SINGLE
Lane2 AS SINGLE
Lane3 AS SINGLE
Lane4 AS SINGLE
AVG AS SINGLE
END TYPE
DIM SHARED Tiger AS TgrRecord
3
CLS
PRINT "Tiger Scout Pinewood Derby Setup"
PRINT ""
PRINT "1) Enter Data"
PRINT "2) Edit Data"
PRINT "3) Delete Data"
PRINT "4) View Data"
PRINT "5) View All Times"
PRINT "6) Update # Of Registered Cars"
PRINT "7) AVG Times"
PRINT "8) Exit"
PRINT ""
PRINT ""
INPUT "What option will you choose"; choice%
SELECT CASE choice%
CASE 1
CHAIN "u:\qbasic\pinewo~1\REGTIGER.BAS"
CASE 2
EditDB
CASE 3
DelData
CASE 4
GetData
CASE 5
RaceSetup
CASE 6
CheckNoRacers
CASE 7
AVG
CASE 8
END
CASE ELSE
GOTO 3
END SELECT
GOTO 3
ErrHndlr:
SELECT CASE ERR
CASE 6
GOTO 3
CASE 75
CLOSE
RESUME NEXT
CASE ELSE
END SELECT
SUB AVG
CHAIN "u:\qbasic\pinewo~1\autoavg"
END SUB
SUB CheckNoRacers
racers% = 0
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
DO WHILE NOT EOF(1)
racers% = racers% + 1
GET 1, racers%, Tiger
IF Tiger.CarNo% > 0 THEN
LOCATE 11, 1: PRINT "There are currently"
LOCATE 11, 20: PRINT Tiger.CarNo%
SELECT CASE MenuRacers%
CASE IS < 10
LOCATE 11, 23
CASE IS > 9
LOCATE 11, 24
CASE IS > 99
LOCATE 11, 25
END SELECT
PRINT "cars registered"
END IF
LOOP
CLOSE
'DO WHILE INKEY$ = ""
'LOOP
END SUB
SUB ChkLane
Chk% = 0
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
DO WHILE NOT EOF(1)
Chk% = Chk% + 1
GET 1, Chk%, Tiger
LOOP
Chk% = Chk% - 1
PRINT Chk%
DO WHILE INKEY$ = ""
LOOP
CLOSE
END SUB
SUB DelData
PRINT "Which Car Number do you wish to delete?"
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
i% = 0
CLS
PRINT " __________________________________________"
PRINT "| LAST NAME | FIRST NAME | car# | weight|"
PRINT "|-------------|-------------|------|-------|"
PRINT "| | | | |"
format$ = "| \ \ | \ \ | ## | \ \ |"
DO WHILE NOT EOF(1)
i% = i% + 1
GET #1, i%, Tiger
IF Tiger.CarNo% > 0 THEN
PRINT USING format$; Tiger.LstNme$; Tiger.FstNme$; Tiger.CarNo%; Tiger.CarOz$
END IF
IF Tiger.CarNo% = 0 THEN
PRINT "| There are NO|entries in th|is dat|abase! |"
PRINT "|_____________|_____________|______|_______|"
PRINT ""
PRINT "Press Any Key To Continue"
DO WHILE INKEY$ = ""
LOOP
CLOSE
GOTO 10000
END IF
LOOP
PRINT "|_____________|_____________|______|_______|"
CLOSE
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
INPUT "What Car Number would you like to delete? (0 = exit)"; delete%
IF delete% = 0 THEN
CLOSE
GOTO 10000
END IF
Tiger.LstNme$ = ""
Tiger.FstNme$ = ""
Tiger.CarNo% = 0
Tiger.Lane1 = 0
Tiger.Lane2 = 0
Tiger.Lane3 = 0
Tiger.Lane4 = 0
Tiger.AVG = 0
PUT #1, delete%, Tiger
CLOSE
10000
END SUB
SUB EditDB
PRINT "Which Car Number do you wish to edit?"
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
i% = 0
CLS
PRINT " __________________________________________"
PRINT "| LAST NAME | FIRST NAME | car# | weight|"
PRINT "|-------------|-------------|------|-------|"
PRINT "| | | | |"
format$ = "| \ \ | \ \ | ## | \ \ |"
DO WHILE NOT EOF(1)
i% = i% + 1
GET #1, i%, Tiger
IF Tiger.CarNo% > 0 THEN
PRINT USING format$; Tiger.LstNme$; Tiger.FstNme$; Tiger.CarNo%; Tiger.CarOz$
END IF
IF Tiger.CarNo% = 0 THEN
PRINT "| There are NO|entries in th|is dat|abase! |"
PRINT "|_____________|_____________|______|_______|"
PRINT ""
PRINT "Press Any Key To Continue"
DO WHILE INKEY$ = ""
LOOP
GOTO 9999
END IF
LOOP
PRINT "|_____________|_____________|______|_______|"
CLOSE
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
INPUT "What Car Number would you like to edit? (0 = exit)"; edit%
IF edit% = 0 THEN
CLOSE
GOTO 9999
END IF
PRINT ""
PRINT ""
INPUT "Last Name? "; Tiger.LstNme$
INPUT "First Name? "; Tiger.FstNme$
Tiger.CarNo% = edit%
INPUT "Weight (in oz.) "; Tiger.CarOz$
INPUT "Lane 1 Time "; Tiger.Lane1
INPUT "Lane 2 Time "; Tiger.Lane2
INPUT "Lane 3 Time "; Tiger.Lane3
INPUT "Lane 4 Time "; Tiger.Lane4
PUT #1, edit%, Tiger
AVG
9999
CLOSE
END SUB
SUB EnterData
1
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
recon% = 0
recno% = 0
DO WHILE NOT EOF(1)
recno% = recno% + 1
GET 1, recno%, Tiger
IF Tiger.CarNo% > 0 THEN
recon% = recno% + 1
END IF
LOOP
5
R% = recon%
CLS
INPUT "Last Name "; Tiger.LstNme$
INPUT "First Name "; Tiger.FstNme$
Tiger.CarNo% = R%
INPUT "Weight (oz.)"; Tiger.CarOz$
Tiger.Lane1 = 0
Tiger.Lane2 = 0
Tiger.Lane3 = 0
Tiger.Lane4 = 0
Tiger.AVG = 0
PUT 1, R%, Tiger
4
INPUT "Enter another? (yes/no) "; ynB$
SELECT CASE ynB$
CASE "yes"
R% = R% + 1
GOTO 5
CASE "no"
GOTO 2
CASE ELSE
GOTO 4
END SELECT
2
CLOSE
END SUB
SUB GetData
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
i% = 0
CLS
PRINT " _____________________________________________________"
PRINT "| LAST NAME | FIRST NAME | car# | weight| avg time | "
PRINT "|-------------|-------------|------|-------|----------|"
PRINT "| | | | | |"
format$ = "| \ \ | \ \ | ## | \ \ | ##.### |"
DO WHILE NOT EOF(1)
i% = i% + 1
GET #1, i%, Tiger
SELECT CASE Tiger.CarNo%
CASE IS > 0
PRINT USING format$; Tiger.LstNme$; Tiger.FstNme$; Tiger.CarNo%; Tiger.CarOz$; Tiger.AVG
CASE 0
END SELECT
LOOP
PRINT "| | | | | |"
PRINT "|_____________|_____________|______|_______|__________|"
CLOSE
PRINT "Press Any Key To Continue"
DO WHILE INKEY$ = ""
LOOP
END SUB
SUB RaceSetup
PRINT "Race Setup"
CLS
OPEN "u:\qbasic\pinewo~1\TgrRecrd.qdb" FOR RANDOM AS #1 LEN = LEN(Tiger)
format2$ = "| ## | ##.### | ##.### | ##.### | ##.### | ##.### |"
PRINT " _____________________________________________________________"
PRINT "| car# | Lane 1 | Lane 2 | Lane 3 | Lane 4 | Avg Time |"
PRINT "|------|----------|----------|----------|----------|----------|"
PRINT "| | | | | | |"
DO WHILE NOT EOF(1)
i% = i% + 1
GET 1, i%, Tiger
SELECT CASE Tiger.CarNo%
CASE IS > 0
PRINT USING format2$; Tiger.CarNo%; Tiger.Lane1; Tiger.Lane2; Tiger.Lane3; Tiger.Lane4; Tiger.AVG
CASE 0
END SELECT
LOOP
CLOSE
PRINT "| | | | | | |"
PRINT "|______|__________|__________|__________|__________|__________|"
PRINT ""
PRINT ""
DO WHILE INKEY$ = ""
LOOP
END SUB
SUB RaceStart
END SUB