Sequential Data File

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Sequential Data File

Postby JasonQuinn1992 » Tue Nov 13, 2012 2:00 pm

how do I create a sequential data file?

Im thinking it looks something like this....


REM*****THIS PROGRAM IS DESIGNED TO CERATE A SEQUENTIAL DATA FILE******

REM*******************PROGRAM VARIABLES****************
REM SPERSONNUM$ SALES PERSON'S NUMBER
REM NAM$ NAME
REM COMMR$ COMMISSION RATE
REM SALAMT$ AMOUNT OFSALARIES

REM *******************MAIN MODULE*********************

GOSUB OpenFile
GOSUB CreateFile
GOSUB CloseFile
PRINT
PRINT " END OF PROGRAM "
END

REM ********************OPEN FILE***********************
OpenFile:
OPEN "F:\SALEDATA" FOR OUTPUT AS #1 ?pl note F is the drive you save
RETURN
REM *******************CREATE FILE**********************
CreateFile:
GOSUB InputSalesmanNum
DO UNTIL SPERSONNUM = 0
GOSUB IputSalesData
GOSUB WriteRecord
GOSUB InputSalesmanNum
LOOP
RETURN
REM *********INPUT SALESMAN NUMBER*********************
InputSalesmanNum:
CLS
LOCATE 9, 14
PRINT "ENTER SALESMAN NUMBER";
INPUT "(ENTER 0 TO END)", SPERSONNUM
RETURN
REM *************SALES DATA******************************
IputSalesData:
LOCATE 11, 14
INPUT " SALESMAN NAME ", NAM$
LOCATE 13, 14
INPUT "ENTER SALE AMOUNT ", SALAMT
LOCATE 15, 14
INPUT "ENTER COMMISSION RATE ", COMMR

RETURN
REM *****************WRITE RECORD TO DISK****************
WriteRecord:
WRITE #1, SPERSONNUM, NAM$, SALAMT, COMMR
RETURN
REM *****************CLOSE FILE***********************
CloseFile:
CLOSE #1
RETURN


Is this correct?


Also, what format should I save this file as? I need to print a report using the data from this sequential file

Return to “QBASIC and QB64 Questions & Answers”

Who is online

Users browsing this forum: No registered users and 4 guests