PLEASE HELP ME! :S

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
PLEASE HELP ME! :S

Post by Guest » Fri Dec 13, 2002 1:06 am

I have a program that keeps giving me a syntax error.  I've had my professor go through it, and most of my classmates, as well as a few other people & NOBODY can find what is wrong...Is anyone online now that can help me?  If so, please send me a message via MSN messenger-- princesshinmighty@hotmail.com

Thanks!
Here is the code:
'*****************************************
'***        Main Driver                ***
'** This is the main driver for the     **
'*  Program.                             *
'*****************************************
GOSUB INIT
GOSUB BUILDIT
GOSUB HEAD
LOOPIT:
GOSUB READIT
GOSUB TABLECHECK
GOSUB PRINTIT
GOTO LOOPIT
'
'****************************************
'********   Initialization **************
'This initializes & sets up the variables for the program
'****************************************
'
INIT:
CLS
MSG$ = ""
BSTS = 0
BSFS = 0
BSRS = 0
BSXS = 0
DCT = 0
TOTP = 0
TOTET = 0
'
'RETURN
'
'****BUILDIT*****
'
BUILDIT:
FOR I = 1 TO 10
'
READ BI(I), ET$(I), DY$(I), RT$(I)
DATA 01, "B747", "T-2", "ORD-DEN"
DATA 02, "B727", "M-T", "DEN-HNL"
DATA 03, "B727", "F-S", "PIT-HNL"
DATA 04, "B737", "SAT", "DSM-OMA"
DATA 05, "B737", "THU", "PIT-HNL"
DATA 06, "B767", "F-SS", "LAX-TYK"
DATA 07, "B747", "W-S", "ORD-LAX"
DATA 08, "DC10", "SUN", "SFO-SEA"
DATA 09, "DC10", "T-W", "SAN-MAM"
DATA 10, "B727", "MON", "LAX-SFO"
NEXT I
'
RETURN
'
'*****HEAD*********
'
HEAD:
PRINT TAB(30); "Fly Right Corporation"
PRINT TAB(31); "Pilot Bid Report"
PRINT
PRINT
PRINT TAB(12); "Bid"; TAB(20); "Pilot's Name"; TAB(37); "Equipment"; TAB(51); "Days Off"; TAB(64); "Route"
PRINT
PRINT
RETURN
'
'*****READIT*******
'
READIT:
READ PN$, BD
DATA "Cyle Adams", 10
DATA "David Berry", 02
DATA "Frank Cone", 07
DATA "George Smiti", 11
DATA "Henry Jordan", 04
DATA "Isaac New", 05
DATA "Ken Phillip",03
DATA "Mike Smith", 01
DATA "Ned Turner", 15
DATA "Tim Snider", 08
DATA END, 999
IF PN$ = "END" THEN GOTO ENDIT
'
'****TABLECHECK****
TABLECHECK:
TOTET = TOTET + 1
'
FOR I = 1 TO 10
IF BD(I) = BI(N) THEN GOTO CALCS
IF BD(I) = 10 THEN MSG$ = "Invalid Bid!": GOTO RETURNIT
GOTO BUMPIT
CALCS:
TOTP = TOTP + 1
IF ET$(N) = "B727" THEN BSTS = BSTS + 1: GOTO RETURNIT
IF ET$(N) = "B747" THEN BSFS = BSFS + 1: GOTO RETURNIT
IF ET$(N) = "B737" THEN BSRS = BSRS + 1: GOTO RETURNIT
IF ET$(N) = "B767" THEN BSXS = BSXS + 1: GOTO RETURNIT
IF ET$(N) = "DC10" THEN DCT = DCT + 1: GOTO RETURNIT
'
BUMPIT:
NEXT I
'
RETURNIT:
RETURN
'
'********PRINT***
PRINTIT:
PRINT TAB(12); BD; TAB(20); PN$; TAB(39); ET$(I); TAB(53); DY$(I); TAB(63); RT$(I);
PRINT TAB(22); MSG$
PRINT
MSG$ = ""
RETURN
'
'****END****
ENDIT:
PRINT
PRINT
PRINT TAB(32); "Equipment Totals"
PRINT
PRINT TAB(33); "Type"; TAB(42); "Total"
PRINT TAB(33); "B747"; TAB(43); BSFS
PRINT TAB(33); "B727"; TAB(43); BSTS
PRINT TAB(33); "B737"; TAB(43); BSRS
PRINT TAB(33); "B767"; TAB(43); BSXS
PRINT TAB(33); "DC10"; TAB(43); DCT
PRINT
PRINT
PRINT TAB(33); "Total Planes:"; TAB(48); TOTET
PRINT TAB(33); "Total Pilots"; TAB(48); TOTP
END

Guest

Re: PLEASE HELP ME! :S

Post by Guest » Fri Dec 13, 2002 1:16 am

Oh yeh, and in the init subroutine, I did get the comment out of there before the return.  Now I'm getting a "Subscript out of range" (And yes I changed all the N's to I's!)

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: PLEASE HELP ME! :S

Post by frankiebaby » Fri Dec 13, 2002 4:34 am

Ok, your problem is simple, i took out a comment on a return statement that seemed in error, and got passed a syntax error problem. your out of range comes from this little section

¦'********PRINT***                                                             _
¦PRINTIT:                                                                      _
¦PRINT TAB(12); BD; TAB(20); PN$; TAB(39); ET$(I); TAB


when it came back to the editor and gave me the error, in the immediate window and typed print I

this gave me an 11 on the screen. well,  only number ten exists on your arrays. DIM the arrays larger if this is an error on size, but it appears not. the problem lies, however, in a FOR loop or somewhere else accessing your I variable. I found that If i put an I = 10 after your RETURNIT: label, the program executed succesfully

by using watchpoints from the debug menu, i found that after every one of your for loops from one to ten, both end up eleven and stop executing

Post Reply