Not All Data is printing

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
JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Not All Data is printing

Post by JasonQuinn1992 »

Hello again guys, so I was working on a program within the syntax error thread... I finally got the program to run but i notice that when i run the program my heading and the first couple lines of my data is missing, can someone help me solve this problem

' Program that lists inventory for your collection of model cars
'
'
'
' Variables Used

' T1$, H1$, H2$, D1$ Print images
' TL$ Print images
' Manufact$ Manufacturer #
' Yr Year Of Car
' Make$ Make of Car
' Model$ Model Of Car
' Desc$ Description of car
' Price Price Of Car
' TotPrice Tot Price Of Cars

' Program Mainline

CLS
GOSUB InitializeVariables
GOSUB PrintHeadings
GOSUB ProcessDetail
GOSUB PrintTotals
END

' Initalize Variables

InitializeVariables:
LET TotPrice = 0
LET T1$ = ""
LET H2$ = " Manufacturer # Yr Make Model Description Price"
LET D1$ = "\ \ ## \ \ \ \ \ \ $ ###.##"
LET TL$ = " TOTAL $ ###.##"
RETURN

'
' Initialize Imagees

InitializeImages:

' T1$ Title Line
' H1$, H2$ Column Headings
' D1$ Deatail (manufacturer #, Yr, Make, description, price)
' TL$ Totals

' PRINT HEADINGS

PrintHeadings:
PRINT T1$; 'Print title line
PRINT
PRINT H1$ 'Print column headings, line 1
PRINT
RETURN


'Process Detail

ProcessDetail:
GOSUB ReadData
DO UNTIL Manufact$ = "END"
GOSUB CalculateTotal
GOSUB PrintDetail
GOSUB PrintTotals
GOSUB ReadData
LOOP

END

CLS

ReadData:
READ Manufact$, Yr%, Make$, Model$, Desc$, Price#
RETURN

PrintDetail:
PRINT USING D1$; Manufact$; Yr%; Make$; Model$; Desc$; Price#
RETURN

MyData:
READ Manufact, Yr, Make, Model, Desc, Price
DATA BMR-R79,49,FIAT,500B,GILLETE RAZOR,7.99
DATA HOTWELS-34,57,CHEVY,NOMAD,4/DR STATION WAGON,12.95
DATA MATCHBX-878,73,FORD,BRONC,3/DR 4X4 RED SPARE WHL,25.99
DATA MATCHBX-72,69,BUIK,CENTY,YELLOW TAXI,1.49
DATA BRM-R88,34,BUGANT,TY575,RACER BLACK ,35.00
DATA MATCHBX-25,80,LINCO,MRKIV,WHITE LIMOUSINE,14.99
DATA LESNEY-Y42,82,CHEVY,MALBU,4/DR GREEN PASSENGER,1.99
DATA HASBRO-119,75,AMC,GRMLN,2/DR SEDAN YELLOW,1.69
DATA TABY-6332,71,TOYOT,CELIC,2/DR SEDAN BLUE,2.99
DATA BMR-SY238,36,ROLRY,SYLVC,4/DR SEDAN BLACK,60.00
DATA "END",0,0,0,0,0,0
' Calculate Total

CalculateTotal:
LET TotPrice# = TotPrice# + Price#
RETURN

' Print Totals

PrintTotals:
PRINT USING TL$; TotPrice#
PRINT
RETURN


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

Post by burger2227 »

Just do ReadData in the loop not ahead of it and take READ line out of the DATA statement too!

Code: Select all

DO
GOSUB ReadData 
IF Manufact$ = "END" THEN EXIT DO
GOSUB CalculateTotal 
GOSUB PrintDetail 
GOSUB PrintTotals 
LOOP
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
JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Post by JasonQuinn1992 »

Thanks for your reply! I did as you said and still see no difference when i print the data....
Post Reply