noob_seeking_help(syntax error)

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Post Reply
azure8bit
Newbie
Posts: 4
Joined: Tue Oct 11, 2016 11:28 pm

noob_seeking_help(syntax error)

Post by azure8bit »

I keep getting a syntax error line 48 on my "READ type$, size, rate, charter, revenue."I am sure it is something simple. I can't figure it out and it's driving me crazy. Any help would be appreciated.

My code:

Code: Select all


'************Mainline*********
cls
gosub InitializeVariable
gosub printheadings
gosub ProcessDetail
gosub printtotals
end

'**************************SET UP CONSTANTS***************************
InitializeVariable:
PAGE.HEADING$ = "                    REPORT TITLE                 PAGE ##"
DETAIL.HEAD.1$ = "type          size      rate      charter    revenue"
DETAIL.type$ = "  \            \ SUBTOTAL          ###        $#####.## "
DETAIL.TOTAL$ = "   \TOTAL REVENUE FOR HOURS CHARTERED\  ###.#"
a1$ = "\            \###       ###        ###        $#####.##"
rt$ = "                  Report Total       ##,###"

RETURN

'**********************READ IN VARIABLE INFORMATION FROM DATA STATEMENTS***********************
PrintHeadings:
PAGE = PAGE + 1
PRINT USING PAGE.HEADING$;Page
PRINT
PRINT DETAIL.HEAD.1$
PRINT

RETURN

'******************Process Detail*********************
processdetail:
gosub readdata
do until Type$ = "EOD"
    gosub printdetail
    gosub calcsubtotal
    typesave$ = TYPE$
    gosub readdata
    if TypeSave$ <> Type$ then
        gosub printsubtotals
    end if
loop

return

'***********************  READ COURSE DATA  *******************************

ReadData:
READ type$, size, rate, charter, revenue
RETURN


'*******************DATA STATEMENTS*************************

DATA RANGER,22,95.00,24
DATA RANGER,22,69.00,12
DATA WAVELENGTH,24,69.00,6
DATA WAVELENGTH,24,69.00,12
DATA CATALINA,27,160.00,24
DATA CATALINA,27,99.00,6
DATA CATALINA,30,190.00,12
DATA CATALINA,30,225.00,24
DATA CORONADO,32,230.00,24
DATA HOBIE,33,192.00,33
DATA HOBIE,33,235.00,24
DATA HOBIE,33,137.00,6
DATA HOBIE,33,235.00,24
DATA C & C,34,290.00,24
DATA C & C,34,175.00,6
DATA CATALINA,36,185.00,6
DATA CATALINA,36,320.00,24
DATA HANS CHRISTIAN,38,250.00,6
DATA EXCALIBER,45,550.00,24
DATA EXCALIBER,45,295.00,6
DATA EOD,0,0,0

'*******************PrintDetail**************************
PrintDetail:
REVENUE = RATE * CHARTER
print using a1$; type$, size,rate,charter,revenue
RETURN

'*******************Calc SubTotal************************

CalcSubTotal:
calsubchar = calsubchar + CHARTER
tot.revenue = tot.revenue + REVENUE


return

'*********************PRINT SUBTOTALS**************
PrintSubtotals:
PRINT
PRINT USING DETAIL.type$;typesave$,calsubchar,tot.revenue
print

chartot = chartot + calsubchar
calsubchar = 0
LINECT = LINECT + 3
typesave$ = TYPE$
RETURN

'*******************Print Totals****************************
PrintTotals:
print using Rt$;CharTot
RETURN




User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: noob_seeking_help(syntax error)

Post by burger2227 »

READ can only read 4 data values, not 5. The decimal point is not a data separator in your data.
You need to either remove one numerical variable or add a numerical one to each DATA line.

So why doesn't it just read the next DATA line? Because it is a STRING value for a number so it errors.
Otherwise it would eventually run out of data.

PRINT USING can use $$ instead of just $ to place the $ immediately in front of the numbers.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
azure8bit
Newbie
Posts: 4
Joined: Tue Oct 11, 2016 11:28 pm

Re: noob_seeking_help(syntax error)

Post by azure8bit »

That solved it! Thank you :D
Post Reply